Next.js Discord

Discord Forum

How to use user cookie to get data on the server side?

Answered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
I'm trying to get data from the server side, but this data relies on cookies to identify the user. I want to know how I can get the user cookie on the server side and send it.

async function getAvatar() {
  const res = await GetAvatar();
  
  if (res.status != 200) {
    return ""
  }

  return res.data.data
}
Answered by Ray
if you using app router
View full answer

3 Replies

are you using app router or page router?
if you using app router
Answer
@Ray if you using app router
Sun bearOP
thank you so much!