Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition to node's fetch #10

Open
coolaj86 opened this issue Aug 29, 2022 · 0 comments
Open

Transition to node's fetch #10

coolaj86 opened this issue Aug 29, 2022 · 0 comments

Comments

@coolaj86
Copy link
Contributor

coolaj86 commented Aug 29, 2022

Node is getting fetch as a default global, but it's not there yet:

(node:7796) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

When Node.js LTS stops issuing that warning we may be able to switch to the webpack-ready browser.js (forthcoming) to being the main for both.

The API would be kept largely the same, but at the very least there will be subtleties that require a breaking change major version bump, so perhaps we'll drop a few old features too.

Why not abandon request in favor of fetch?

In many cases that should be done, but there are a few things - such as handling opts.auth- that require a small amount of utility code.

Node's fetch vs WHATWG fetch

See https://github.com/nodejs/undici/#specification-compliance.

In summary:

  • you must consume or cancel the body
  • you can get and set forbidden headers, such as Set-Cookie, Cookie and User-Agent
  • (duh) Node buffers and Node streams are allowed
  • caching is (probably?) not supported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant