Is there any issue if i use this as a api of `/api/user/[userId]`
Answered
Αμμάν Ριζουάν posted this in #help-forum
Answered by B33fb0n3
I guess I already linked you the correct link. Take a look at it here: https://nextjs.org/docs/app/building-your-application/routing/route-handlers#dynamic-route-segments
You might be interested in directly viewing at the code:
You might be interested in directly viewing at the code:
// route: app/items/[slug]/route.ts
export async function GET(
request: Request,
{ params }: { params: Promise<{ slug: string }> }
) {
const slug = (await params).slug // 'a', 'b', or 'c'
}
10 Replies

@Αμμάν Ριζουάν Click to see attachment

No. Your way of getting the dynamic param is a bit weird, but the rest is fine

@B33fb0n3 No. Your way of getting the dynamic param is a bit weird, but the rest is fine

So how can i get a param ??
I have seen this in YT tutorial if you have a better way then please share

@Αμμάν Ριζουάν So how can i get a param ??

I guess I already linked you the correct link. Take a look at it here: https://nextjs.org/docs/app/building-your-application/routing/route-handlers#dynamic-route-segments
You might be interested in directly viewing at the code:
You might be interested in directly viewing at the code:
// route: app/items/[slug]/route.ts
export async function GET(
request: Request,
{ params }: { params: Promise<{ slug: string }> }
) {
const slug = (await params).slug // 'a', 'b', or 'c'
}
Answer

It is not working for api route

@Αμμάν Ριζουάν It is not working for api route

you need to exchange your stuff here to the code I already wrote. Also make sure to change the
slug
to your userId
, as the folder path is different

Ok let me check again

Hmm it working
Thanks

happy to help