Why it took so long? e.g. Deno had fetch support for ages
Basically because fetch isn't a great API for servers it took a while to get consensus on actually landing it for the interoprability/simple API value. Then it took a while to get consensus it's fine to do even if we can't implement the standard fully and diverge from it on stuff like CORS (like Deno does). Then there were a bunch of work adding APIs like `EventTarget` and `AbortSignal` to Node.js which are quirky'is…
Fetch API has landed into Node.js
31–40 of 210 posts
Re: Fetch API has landed into Node.js
#32Hey, 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.
Quick question, judging from the commit alone this seems like a rather small change. I assume there's more to it though. I just wonder how come features like this that kind of seems obvious to include in the ecosystem takes quite some time to land? I understand the reality is more complex perhaps, so I am genuinely curious. I hope you realize no disrespect, this will greatly improve the daily work for me since I use…
Re: Fetch API has landed into Node.js
#33Hey, 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.
Quick question, judging from the commit alone this seems like a rather small change. I assume there's more to it though. I just wonder how come features like this that kind of seems obvious to include in the ecosystem takes quite some time to land? I understand the reality is more complex perhaps, so I am genuinely curious. I hope you realize no disrespect, this will greatly improve the daily work for me since I use…
> I just wonder how come features like this that kind of seems obvious to include in the ecosystem takes quite some time to land?
I answered that below (check it out) but note how expensive adding a bad API is vs. asking people for one more `npm install` :) There is more discussion in https://github.com/nodejs/node/issues/19393 and in https://docs.google.com/document/d/1tn_-0S_FG_sla81wFohi8Sc8... a discussion from 2018 we had on it
Re: Fetch API has landed into Node.js
#34Hey, 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.
Quick question, judging from the commit alone this seems like a rather small change. I assume there's more to it though. I just wonder how come features like this that kind of seems obvious to include in the ecosystem takes quite some time to land? I understand the reality is more complex perhaps, so I am genuinely curious. I hope you realize no disrespect, this will greatly improve the daily work for me since I use…
And with every public API: Once you add it, you can't really hope to ever change it and even bug-fixes could be breaking some user's code (because they relied on the bug), so you have to be very careful to ship your public API as bug-free as possible.
Re: Fetch API has landed into Node.js
#35Hey, 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.
This was a huge pain for us. We develop an SDK that needs to work on Node, browsers and React Native.
I am super happy to hear about this :)
Re: Fetch API has landed into Node.js
#36sorry if this is a stupid question, but how do I try this out? I ran node with the experimental flag on a file that calls fetch: node server.js --experimental-fetch Got 'fetch is not defined' reference error.
This _just landed today_. You can get it by building from master:
```
# there is more details in building.md
git clone https://github.com/nodejs/node
cd node
# may need to pass --openssl-no-asm
./configure
make -j12
./out/Release/node --experimental-fetch
```
Otherwise - wait a bit for the next v17 release to land per the normal release cycle :)
Re: Fetch API has landed into Node.js
#37sorry if this is a stupid question, but how do I try this out? I ran node with the experimental flag on a file that calls fetch: node server.js --experimental-fetch Got 'fetch is not defined' reference error.
First: not a stupid question - the release cadence, multiple release lines and other minutia of a project like Node are not something I'd expect users to be intimately familiar with! This _just landed today_. You can get it by building from master: ``` # there is more details in building.md git clone https://github.com/nodejs/node cd node # may need to pass --openssl-no-asm ./configure make -j12 ./out/Release/node --…
node server.js --experimental-fetch
Re: Fetch API has landed into Node.js
#38Earlier quoted context omitted.
Hey this one change is going to positively impact my day to day life. Just wanted to let you know. Thanks for sharing your hard work and time.
I'm happy to hear that but I had a very small part in it all! The person who took it through the finish line (and deserves the most props here IMO) is Michael https://github.com/targos The people who worked most on Undici are Matteo https://github.com/mcollina and Robert https://github.com/ronag The person to work most on fetch in Undici is Ethan https://github.com/Ethan-Arrowood Also worth calling our James whose wo…
Re: Fetch API has landed into Node.js
#39Earlier quoted context omitted.
However note that ESM in Node comes with drawbacks that prevent end-users from relying them in various situations. Those will be mostly solved once loaders become stable, but until then it's still advised to ship packages as both CJS and ESM.
How do you do both?
For example to use `require` inside ESModules you would do:
```mjs import { createRequire } from 'module'; const require = createRequire(import.meta.url); require('./whatever-in-cjs'); ```
There is a reason this isn't "by default" though since ESM doesn't "silently" interop with CJS to not make writing universal code harder.
Re: Fetch API has landed into Node.js
#40Earlier quoted context omitted.
Quick question, judging from the commit alone this seems like a rather small change. I assume there's more to it though. I just wonder how come features like this that kind of seems obvious to include in the ecosystem takes quite some time to land? I understand the reality is more complex perhaps, so I am genuinely curious. I hope you realize no disrespect, this will greatly improve the daily work for me since I use…
The commit adds undici (another Node.js project at https://github.com/nodejs/undici ) as a dependency and exposes its `fetch` - the code changes you see are probably just adding a flag :) > I just wonder how come features like this that kind of seems obvious to include in the ecosystem takes quite some time to land? I answered that below (check it out) but note how expensive adding a bad API is vs. asking people for…
Last question I have is will this be included in the next version of the LTS version or how do experimental features usually progress for someone who are unfamiliar?
Can't wait until I can use fetch in my codebase without any additional dependencies!