How to use fetch in Node.js? Getting 'fetch is not defined' error Alternatively, if you want something more

12 Replies, 1295 Views

Wait, really? I thought fetch in nodejs was a thing now! Guess not.

I’ve been using axios forever—it’s way more reliable for API calls in nodejs IMO. The syntax is clean, and it handles errors better.

Try:
`npm install axios`

Then:
`const axios = require('axios');`

Bonus: it works in browsers too, so you can reuse code.

Messages In This Thread



Users browsing this thread: 1 Guest(s)