JavaScript fetch ReferenceError: fetch is not defined

0
2 comments

The fetch API is not implemented in Node.js, native support for it is only available in browsers. You need to use an external module for that, and a good one is node-fetch. After installing the module in your Node application, just add the line below to the top of the files where you are calling the fetch API:

var fetch = require("node-fetch");
2

@Elena Pogorelova - Thanks this helped me

1

Please sign in to leave a comment.