Sometimes, we want to fix ‘ReferenceError: fetch is not defined’ error in Node.js.
In this article, we’ll look at how to fix ‘ReferenceError: fetch is not defined’ error in Node.js.
How to fix ‘ReferenceError: fetch is not defined’ error in Node.js?
To fix ‘ReferenceError: fetch is not defined’ error in Node.js, we can install node-fetch
.
To install it, we run
npm i node-fetch
Then we import it with
import fetch from "node-fetch";
so we can call fetch
.
Conclusion
To fix ‘ReferenceError: fetch is not defined’ error in Node.js, we can install node-fetch
.