DEV Community

Discussion on: Testing Next.js pages - Little Bits

 
matiasbacelar98 profile image
Matias Bacelar

I solve the problem using fetch-node thanks for answering anyway!

Thread Thread
 
alilop profile image
Alicia Lopez

Hello Matias I am having the same issue trying to test GetServerSideProps, but keep getting the "fetch is not defined". How did you solve it exactly via fetch-node? I am failing so far... Thank You in advace!

Thread Thread
 
maciekgrzybek profile image
Maciek Grzybek

Native fetch is only accessible in the browser and Next is using SSR, which means you have to use something that can be used in the server as well instead. Node fetch or axios for example

Thread Thread
 
matiasbacelar98 profile image
Matias Bacelar • Edited

As Maciek said, native fetch was not possible, that's why I used fetch node but it would go with axios anyway especially because there is a good chance that you are using it on the client. Cheers