Why isn't fetch in Node.js working like it does in the browser? or What's the best way to use fetch i

16 Replies, 1537 Views

yep, fetch in nodejs is kinda new as a native thing. if you’re on node <18, you gotta install node-fetch (or undici, which is what node’s fetch actually uses under the hood).

pro tip: if you’re using ESM, make sure to import it right—`import fetch from 'node-fetch'` vs require() can trip you up.

axios is more stable for older projects, but fetch is fine if you’re up-to-date!

Messages In This Thread



Users browsing this thread: 1 Guest(s)