Next.js Discord

Discord Forum

api data fetching with serversideprops in nextjs not working

Unanswered
American Sable posted this in #help-forum
Open in Discord
American SableOP
im trying to fetch api data from postman to my nextjs project with serversideprops but this shows up, how do i fix it?

10 Replies

@joulev `props.product` is undefined, as the error says
American SableOP
umm yea how do i fix it bro?im kinda new at this
@American Sable umm yea how do i fix it bro?im kinda new at this
oh didn't notice at first, could've given you a more helpful answer

since you are using the app router you simply don't have getserversideprops. instead use server components: https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#server-side-rendering-getserversideprops
the page i linked to has these examples, have you read this part?
@American Sable so if i re-install the project without the app router will i be able to use getserversideprops???
if you use the pages router then you do have getserversideprops; if you want to use the pages router then just create it
make a pages/index.tsx
and make your page there