Live data from Hacker News

Fetch API has landed into Node.js

github.com

201–210 of 210 posts

Re: Fetch API has landed into Node.js

#201
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…

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.

I didn't downvote, but my guess is its primarily a kneejerk reaction to the following line:

> set JSON as the default request content type

or something similarly subjective.

Downvoting is going a bit too far, but bundling a few individual opinions on defaults alongside broadly accepted (implemented in both Node & Deno after much discussion) features seems... presumptuous.

Re: Fetch API has landed into Node.js

#202

Earlier quoted context omitted.

> Does anyone who knows enough JavaScript point me in the right direction about it. I find all this very confusing. There isn't a straight forward solution, but the closest for me is the combination of using a transpiler (Babel), and a bundler (Webpack). A common criticism on node/javascript projects is the boiler plate setup required. As far as I know, there isn't an IDE that takes care of doing this part for you, w…

there isn't an IDE that takes care of doing this part for you Did you try WebStorm? Any setup specifics that it doesn't support for you?

I've tried WebStorm in the past, but it was prior to the explosion of application development with javascript.

At the time, I was using sublime, and now I use AWS Cloud9 exclusively.

Re: Fetch API has landed into Node.js

#203
post #200

Every Node.js dev should be thanking the Deno creators. It has forced them off of their "this is how Node does it" complacency. Most improvements I notice and care about on Node these days are all things that Deno already supports (fetch, ES modules, async std lib uses promises, etc). The Web Platform APIs aren't perfect, but they are better, and more thoroughly thought out than Node's.

What is "this is how Node does it" complacency you speak of? Node has been talking about Fetch since at least 2018 _before_ Ryan even announced Deno. This is true for promises, ESModules etc. Ryan _attended those meetings_ in the Node collaborator summit. Don't get me wrong I am thankful for Deno (and a contributor!) but: - It's a lot easier to make changes when the project is new and you don't have a lot of users (w…

@dang I can't seem to be able to edit this is there any way to fix the formatting by any chance?

Re: Fetch API has landed into Node.js

#204

Wow I can't believe how light years ahead Deno is than Node. You want imports you want fetch you want TS, use Deno.

Why can't you use TypeScript with node? It's not built in, but it's easy enough to use by building or running it with ts-node. Also, once you are using TypeScript, you have import syntax support. Deno has chosen a different path, but there are definite trade-offs.

Yup the point I'm making is its built in. no hoops no babel. I find myself gravitating towards Deno before Node because with node I know I'll have to do some hoop jumping to make it work.

Re: Fetch API has landed into Node.js

#205

Wow I can't believe how light years ahead Deno is than Node. You want imports you want fetch you want TS, use Deno.

Yes, and the go light years back in ecosystem ;)

sort of. There's only been one instance for me that this has caused any issues... I ended up just writing my own version of the missing tool. Deno has almost parity with node at the moment though https://deno.land/std@0.123.0/node.

Re: Fetch API has landed into Node.js

#206

Earlier quoted context omitted.

why are you writing node applications without using package.json? it sounds like you're looking to have a problem with javascript tbh. don't use it, whatever

There is absolutely no need for a package.json when using ES6 imports without a build step. Package.json doesn't do anything when I'm loading the code in a browser, why would I have to use it when I want to run the same JS code with node?

this is a silly point. it's a different runtime, there are also different apis available - as is the point of this article. node is not an internet browser. but ok

Re: Fetch API has landed into Node.js

#207
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.

Thank you for making "fetch" happen

underrated comment

Re: Fetch API has landed into Node.js

#208
post #132
post #129

Earlier quoted context omitted.

Is there support for timeouts? It's the main reason I use https://github.com/sindresorhus/got

You can use timeouts through `AbortController/AbortSignal` - eventually it'll even be built in with `AbortSignal.timeout` which is currently under-works in the spec level.

No, thanks. I'll stick with got.

Re: Fetch API has landed into Node.js

#210
post #159
post #131

Earlier quoted context omitted.

This is very new and the implementation _just_ landed today so it makes sense Deno would be faster with an API they have been working on for years. I am confident that Node's implementation will _eventually_ have comparable performance. That said: please do open an issue in the undici repo at https://nodejs.org/node/undici so this gets tracked.

That URL gives me a 404 – should it be https://github.com/nodejs/undici ?

Thanks. Filed: https://github.com/nodejs/undici/issues/1203
Post reply on HN