I am a Software Engineer and Developer Advocate who loves sharing knowledge via writing, videos, mentorship, and working out. Please Subscribe: https://www.youtube.com/channel/UCcz5Bvr4kGHPFAjvnRhIQ4g
I am a Software Engineer and Developer Advocate who loves sharing knowledge via writing, videos, mentorship, and working out. Please Subscribe: https://www.youtube.com/channel/UCcz5Bvr4kGHPFAjvnRhIQ4g
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.
I am a Software Engineer and Developer Advocate who loves sharing knowledge via writing, videos, mentorship, and working out. Please Subscribe: https://www.youtube.com/channel/UCcz5Bvr4kGHPFAjvnRhIQ4g
What are you using for data fetching?
If apollo then see next.js apollo example, apollo needs additional code for SSR
I use node-fetch.
Maybe I should tryout Appolo then
Apollo is only for graphql
Are you getting any error?
No errors. Nothing comes up in my console at all.
That’s more reason why it is frustrating 😆
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 replacenode-fetch
withisomorphic-fetch
, which will give you an equivalentfetch
method you can safely use in both environments.Thank you Louis. I will check that out