Live data from Hacker News

Fetch API has landed into Node.js

github.com

111–120 of 210 posts

Re: Fetch API has landed into Node.js

#111
post #4

Hey, 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.

Really happy to see fetch() merged into core! Looking at the PR, what are those WASM blobs in Undici and how is it that Node.js accepts a random very large compiled blob instead of asking for the source file + compilation step? https://github.com/nodejs/node/commit/6ec225392675c92b102d3c...

Re: Fetch API has landed into Node.js

#112
post #4

Hey, 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.

Really happy to see fetch() merged into core! Looking at the PR, what are those WASM blobs in Undici and how is it that Node.js accepts a random very large compiled blob instead of asking for the source file + compilation step? https://github.com/nodejs/node/commit/6ec225392675c92b102d3c...

Those wasm blobs are Node's own llhttp https://github.com/nodejs/llhttp in wasm to speed up HTTP parsing. The project itself added as a dependency is also by Node https://github.com/nodejs/undici .

The question is totally legitimate but please assume core doesn't make "load random binary" level kind of goofs :)

Re: Fetch API has landed into Node.js

#113
post #4

Hey, 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.

pretty great. I've been using undici for a while now and very happy with the speed and experience.

Re: Fetch API has landed into Node.js

#114
post #4

Hey, 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.

Great work!

Curious to check but quick question: does it support upload progress? If not, is it considered?

Re: Fetch API has landed into Node.js

#115

Earlier quoted context omitted.

Does it have to be a buy-in, though? You could agree on server-specific extensions to fetch and codify them in the same spec (so it doesn't get lost otherwise). Browser vendors wouldn't need to implement it but they will still keep an eye on it when working on future browser apis.

Codifying the redirect behaviour for server/"trusted" envs makes some sense with Deno/node doing the same thing. I'm not versed enough in the standards orginazation politics to say if that's viable though. The rest of your "improvements" aren't that. They're opinions, opinions laser focused on a JSON centric api. I'm sorry to say this, but not all of the web is one big JSON blob. Some of us have to talk to SOAP (xml)…

Can you share your setup for talking to SOAP services?

Re: Fetch API has landed into Node.js

#116
post #58
post #50

Earlier quoted context omitted.

A better idea would be to replace / improve the fetch spec. Handle redirects, set JSON as the default request content type, encode URI components for users, decode response bodies with JSON headers as JS objects, etc. Right now most developers either write their own library to do these things on top of fetch or another HTTP client or use a third party library from npm. A new standard would allow us to make http reque…

A new standard would need buy-in from browsers to actually be a standard. Browsers likely don't have a lot of incentive to make spec changes only Node is interested in (like making the whole spec more complicated from their point of view because of Node's (or Deno's) different security model). The level of collaboration and good-faith we've been getting from spec bodies like WHATWG is very high as it is and we really…

> Browsers likely don't have a lot of incentive to make spec changes only Node is interested in

All the existing HTTP clients discussed in the previous post also run in the browser.

Re: Fetch API has landed into Node.js

#117
post #76

Earlier quoted context omitted.

And so are navigator, localStorage and classes under window, like EventTarget.

Yeah. What's your point?

Comments like “it’s standard” do not answer the original question:

“I'm curious why Node core has decided to make this an official part of Node?”

The standard describes many functions and classes. What makes fetch more land-able than e.g. the event system, of which node has incompatible implementation? Or feature detection via navigator. Why it? What were the main point(s) of adding fetch specifically?

Re: Fetch API has landed into Node.js

#118
post #15

Why it took so long? e.g. Deno had fetch support for ages

Because Node is legacy and Ryan Dahl moved on to Deno... Node is just an outdated 'standard' at this point.

I don't think that's an accurate characterization of the fork.

Re: Fetch API has landed into Node.js

#119

Earlier quoted context omitted.

Why is this being down voted? This comment seems to be making a reasonable case. In case you disagree, you may want to reply why instead of down voting.

Because fetch just landed in Node.js, making it a standard present in every context after like 5 years and he want to change the standard now. Edit: also, you are being downvoted because the etiquette on HN are that you don't ask "why was X downvoted".

As mentioned existing HTTP clients had this behaviour back in 2012, the designers of fetch chose to ignore these cowpaths in favour of a more minimal implementation requiring the use of third party HTTP clients in both browsers and node, simply to have reasonable defaults and not repeat oneself, for the foreseeable future.

Re: Fetch API has landed into Node.js

#120
post #106
post #71

Earlier quoted context omitted.

I second this, since fetch is a wrapper around xhr (though doesn’t have to be because node is a non-restricted runtime), and it diverged already for redirect semantics. It’s news, but is it big?

> It’s news, but is it big? As someone who has been working almost exclusively on Node.js applications for years now, this is big. Front-end developers have, for years, enjoyed this wrapper around the clunky XHR API. It is simple, intuitive, and it comes _free_ in the browser environment (and was easily shimmable before it was standard). Additionally, the depreciation of the popular request[0] a while ago, there has…

npm i request node-fetch make-fetch-happen axios. Just out of top of my head.
Post reply on HN