Next.js Discord

Discord Forum

Dynamic Route Segments and response

Unanswered
Japanese flying squid posted this in #help-forum
Open in Discord
Japanese flying squidOP
I'm currently trying to use /app/api/user/[id]/route.ts to get a user by it's id on my backend (Nest js)
I have seen in the documentation that :

export async function GET(
  request: NextApiRequest,

  { params }: { params: { id: string } }
) {
  const userId = params.id;
...

Should work. It does in fact.
But i also use NextAuth to save my jwt tokens, i have to put them into my request for the backend to work.

Here is my problem :

To get them i have to use :
**const session = await getServerSession(request, response, authOptions);**


But i cannot find a way to get them in the parameter of GET with params.
Also
getServerSession
ask for
NextApiRequest
and not normal
NextRequest
is it normal ?
If someone have advices i would be so grateful !!!

0 Replies