DEV Community

Discussion on: Must I use Nextjs Data Fetching Methods?

 
lalabadie profile image
Louis-André Labadie

node-fetch is specifically a NodeJS library. With Next, if a page is rendered on the server, it will run in a Node environment. If it's rendered by the browser, it will run in the browser.

If you try to use node-fetch in the browser, it will probably fail. What you can try is to replace node-fetch with isomorphic-fetch, which will give you an equivalent fetch method you can safely use in both environments.

Thread Thread
 
ebereplenty profile image
NJOKU SAMSON EBERE

Thank you Louis. I will check that out