Live data from Hacker News

Fetch API has landed into Node.js

github.com

161–170 of 210 posts

Re: Fetch API has landed into Node.js

#161
post #156

Earlier quoted context omitted.

Has it ever occurred to you that your users can (a) see all requests you make to third party services, including your credentials and client secrets, (b) modify and replay those requests at will and (c) spoof responses from those services?

I think the misunderstanding is, beyond special cases like a payment processing, why would you be calling third party services from your service? When I think of calling a 3rd party HTTP API, I am thinking of public APIs, like say a widget that shows the weather in a users area.

Sure - but that weather/map/whatever widget might be paid, and unless you want to pay for others' API usage, you should make the relevant API calls from your backend, not frontend. Also consider caching 3rd party service replies, etc.

Re: Fetch API has landed into Node.js

#163
post #119

Earlier quoted context omitted.

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.

the value the js community gets from `fetch` being a unified standard is far, far greater than the benefit you as a developer would get from not having to add 15 extra LOC around `fetch`, that you'll probably hide behind a `fetchJSON` function anyway.

Re: Fetch API has landed into Node.js

#164

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.

Re: Fetch API has landed into Node.js

#165
post #91
post #36

Earlier quoted context omitted.

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

Just slightly related to this - I wish I could ask GitHub to send me an email when specific release are available for the repo!

You can subscribe to only releases on github.

Re: Fetch API has landed into Node.js

#166
post #18

Earlier quoted context omitted.

Those have been supported for several years now :) You need to tell Node to use the format by either naming your file `.mjs` or setting `"type": "module"` in your `package.json` file. > Also why do so many libraries have this strange 5 line header code for this umd, amd, business. Is that to make their packages work with nodejs? That's just old for "adapt the module system" from the old days and libraries just didn't…

"supported" is somewhat of a misnomer IMHO. It's only supported if the other tools you're using support ESM. Otherwise, it's not. And it's really annoying when libraries choose to go full ESM because it breaks things like tests and deployments in weird ways. It's a pain in the ass.

Node supports ESM, full stop.

Re: Fetch API has landed into Node.js

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

Does it mean we have a built-in FormData in Node.js core for multi-part requests?

Re: Fetch API has landed into Node.js

#168

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

Seriously. I maintain an open-source Node.js CLI utility and was shocked when import/export syntax is only achievable if you use a transpiler like Babel. Such overkill for something that’s been in the JS spec for nearly a decade.

Re: Fetch API has landed into Node.js

#169
post #28

Earlier quoted context omitted.

How do you do both?

Usually you setup a transpiler to target both. For example, my packages are bundled with rollup towards both cjs & esm: https://github.com/arcanis/clipanion/blob/master/rollup.conf...

Helpful, thank you!

Re: Fetch API has landed into Node.js

#170
post #19
post #7

Earlier quoted context omitted.

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.

This is an understatement. With fetch available in node, we have a single, standardised, promise-based HTTP client Interface available on all (more or less common) JavaScript platforms. This is great news for an ecosystem traditionally extremely fragmented and may lead the way to more consolidation in the JS library space.

NodeJS API are traditionally not promised based (although nowadays some do offer a promisified option), so I'm not especially excited to have a promise-based API :)

It's a great news for people doing both front end and backend I guess, but for people doing NodeJS développement it's just one more option to do http request (which I guess is going to be very similar to the module node-fetch that have existed for a while, without special consolidation effect)

Post reply on HN