Dynamic route undefined slug in route handler.
Answered
Clown posted this in #help-forum
ClownOP
I am using NextJS 13.4.7. I am using a dynamic route(route handler/app directory) and the slug seems to return undefined:
The slug returns undefined as can be seen. If its any help, i am fetching this in a middleware.
app/api/organization/[userid]/route.tsimport { NextResponse } from "next/server";
export async function GET(
request: Request,
{ params }: { params: { slug: string } },
) {
const slug = params.slug;
console.log(request.url);
console.log(slug);
return new NextResponse("Hello From Organization route! User ID: ", {
status: 200,
});
}output:http://localhost:3000/api/organization/64e32b2bcc2a4d4805639847
undefinedThe slug returns undefined as can be seen. If its any help, i am fetching this in a middleware.
Answered by European sprat
err "userid"
it maps to whatever the folder is named as with
it maps to whatever the folder is named as with
[userid]4 Replies
European sprat
it's "userId" not "slug"
European sprat
err "userid"
it maps to whatever the folder is named as with
it maps to whatever the folder is named as with
[userid]Answer
ClownOP
oh did i miss that in the documentation or its just not written correctly :/
thanks anyways