Some issue with fetching in Next
Unanswered
DhrishP1 posted this in #help-forum
DhrishP1OP
My fetch req url in next js is only fetching the first element of an array of objects but the same url is fetching the whole array in thunderclient and postman. I have checked everything , also made revalidation = 0 and restarted the localhost but stil isn't working , is there some problem going on with Next regarding fetching?
I tried everything and even checked the github repo of the tutorial I am referencing but still only the first element is getting fetch and also checked the .env URL twice
I tried everything and even checked the github repo of the tutorial I am referencing but still only the first element is getting fetch and also checked the .env URL twice
26 Replies
DhrishP1OP
I didn't use axios because I didnt wanted any more dependencies
European sprat
What's the API code look like
@European sprat What's the API code look like
DhrishP1OP
It's proper
See the thunderclient picture
It is working fine there
European sprat
I don't see the API code
@DhrishP1 My fetch req url in next js is only fetching the first element of an array of objects but the same url is fetching the whole array in thunderclient and postman. I have checked everything , also made revalidation = 0 and restarted the localhost but stil isn't working , is there some problem going on with Next regarding fetching?
I tried everything and even checked the github repo of the tutorial I am referencing but still only the first element is getting fetch and also checked the .env URL twice
looks like you are trying to fetch a server side api request. dont do that
just get the data directly
after hard refreshing
the data is updated , the revalidation is not working
Huntaway
hello sorry its urgent can i ask question here
Huntaway
basically i am using next auth for discord after ad adapter for database but session get null in jwt and session event
DhrishP1OP
look into callbacks
in nextjs docs
Huntaway
and there a error
[next-auth][error][SESSION_ERROR]
https://next-auth.js.org/errors#session_error Cannot read properties of undefined (reading 'accessToken') {
message: "Cannot read properties of undefined (reading 'accessToken')",
stack: "TypeError: Cannot read properties of undefined (reading 'accessToken')\n" +
' at Object.session (webpack-internal:///(api)/./src/pages/api/auth/[...nextauth].js:84:41)\n' +
' at Object.session (/workspace/WEB2.0/node_modules/next-auth/core/routes/session.js:117:48)\n' +
' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
' at async AuthHandler (/workspace/WEB2.0/node_modules/next-auth/core/index.js:165:27)\n' +
' at async NextAuthApiHandler (/workspace/WEB2.0/node_modules/next-auth/next/index.js:22:19)\n' +
' at async NextAuth._args$ (/workspace/WEB2.0/node_modules/next-auth/next/index.js:106:14)',
name: 'TypeError'
}DhrishP1OP
dm me the code and delete these chats
@DhrishP1 I didnt get it
dont call your own server api from a server component
@DirtyCajunRice | AppDir dont call your own server api from a server component
DhrishP1OP
That was from another server
I was calling 3000 from 3001
ah. wasnt clear. glad its fixed