Node - Fetch Is Not Defined


2 min read

How to fix ReferenceError: fetch is not defined

  • Error encountered when testing async function.

  • Run npm install node-fetch--save.

  • Add const fetch = require('node-fetch') at the top of the .js file containing the class and the corresponding test file.

Previous post:
Node - Hide API Key
Next post:
JavaScript - Async Await

Discussion