Categories
JavaScript Answers

How to fix ‘ReferenceError: fetch is not defined’ error in Node.js?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *