Fetch is not defined version 17.7.2 using –experimental-fetch

Version

17.7.2

Platform

21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

fetch({ url: "https://swapi.dev/api/people/1", method: "GET"}).then((response) => response.json).then((response) => { console.log(response); })

node fetch.js –experimental-fetch

fetch is not defined

How often does it reproduce? Is there a required condition?

All of the time

What is the expected behavior?

fetch is defined

What do you see instead?

fetch({
^

ReferenceError: fetch is not defined

Additional information

No response

1 thought on “Fetch is not defined version 17.7.2 using –experimental-fetch

  1. node fetch.js –experimental-fetch

    You need to swap your arguments around so that Node.js sees --experiment-fetch instead of passing it as an argument to fetch.js:

    node --experimental-fetch fetch.js
    

Comments are closed.