octokit / octokit.js

The all-batteries-included GitHub SDK for Browsers, Node.js, and Deno.
MIT License
6.93k stars 1.01k forks source link

Throw a helpful error when `fetch` is not set #2497

Closed oscard0m closed 1 year ago

oscard0m commented 1 year ago

Maybe we could add a section to the README and link to it from the error, so we can provide a more thorough explanation and most importantly we can update whenever needed.

I'd say the availability of fetch is independent of the Node version. fetch is still experimental and it can be disabled with --no-experiemental-fetch. Also Node is not the only place where Octokit is run, I'm not sure if e.g. Electron or React Native have a global fetch method.

I'd do something like this:

fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing

Originally posted by @gr2m in https://github.com/octokit/octokit.js/issues/2486#issuecomment-1633271530

gr2m commented 1 year ago

should we rename this issue to

Throw a helpful error when fetch is not set

I don't think the error is really about Node 14/16 compatibility