Fetch API has landed into Node.js
github.com
Fetch API has landed into Node.js
1–10 of 210 posts
Re: Fetch API has landed into Node.js
#2Re: Fetch API has landed into Node.js
#3https://www.npmjs.com/package/undici
However the fetch implementation itself is documented as unstable and only supports Node 16.x. I believe this is because it is not quite spec compliant yet, so there is latitude for breaking changes that make it more spec compliant.
Re: Fetch API has landed into Node.js
#4This is still experimental and we'd love to hear from the community what you'd like to see.
Re: Fetch API has landed into Node.js
#5Re: Fetch API has landed into Node.js
#6For those of us unfamiliar, how long until stuff comes out of experimental?
For `fetch` it will take us around a year or two probably.
I wrote more details on the PR itself but I (and others) basically feel strongly that it should be as close to compliant as possible (Deno have a nice list which they happily shared with us of how they diverge and that seems reasonable).
Basically there is a bunch of stuff that should happen first:
- We need to run (and pass) the web platform tests.
- We want to go over the spec (again) and check compliance and add more tests and fix bugs.
- We want community feedback on the implementation and to improve the DX to be better (while not sacrificing spec compliance).
- We want better support for stuff like `File` in core.
- Web streams need to go out of experimental first.
This was a _long_ road that had many stepping stones (like EventTarget, AbortController, Blob, ReadableStream etc). It's important to get it right.
Worth mentioning the fact it's experimental doesn't mean it's not safe to use in simple code in this case - it just means if you make your code behave in a way that diverges from the specification we may change our implementation to match the specification and break your code.
Anything like `await fetch('./someUrl').then(x => x.text())` should be fine.
Re: Fetch API has landed into Node.js
#7Brief explanation?
I think the only benefit it that it makes it easier to share code between front end and back end.
Re: Fetch API has landed into Node.js
#8For those of us unfamiliar, how long until stuff comes out of experimental?
Re: Fetch API has landed into Node.js
#9Brief explanation?
Fetch is a web JS API to do HTTP requests. NodeJS has its own API to do HTTP requests. This add supports for the fetch API. I think the only benefit it that it makes it easier to share code between front end and back end.
Re: Fetch API has landed into Node.js
#10Hey, Node core person here (and the person who triggered the land) - we're super excited for this and would love help and feedback. This is still experimental and we'd love to hear from the community what you'd like to see.
It's still very common to see Node modules that use require(), for example, but would otherwise work flawlessly in a browser where there is no require() support (without using shims and other libraries).