How to access the current user session data through api routes using NextJS #3386
-
Question 💬0 I'm trying to access data from the current user session after user authentication in a file inside the Api routes from NextJS, but in the console.log(session.user.email) returns null even after the authentication. Does someone know how to do it?
How to reproduce ☕️
The problem is that I can't get the current user from session.user.email in api/users route to list all favorite user games correctly. Contributing 🙌🏽No, I am afraid I cannot help regarding this |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 8 replies
-
you have to pass https://next-auth.js.org/getting-started/client#server-side-example |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Thank you very much! It has worked fine! If desired, consider this topic as closed. |
Beta Was this translation helpful? Give feedback.
-
In post method I am getting session is null but in GET request, able get session. how ? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
const session = await getSession({req})