News for hackers. Stuff that matters.
Re:Fetch API has landed into Node.js by neves on Tuesday February 01, 2022 @09:47AM (#30163133)
Where can I find an explanation about what is Fetch and why it should be in Node.js?
Re:Fetch API has landed into Node.js by tehbeard on Tuesday February 01, 2022 @11:40AM (#30165114)
fetch is a "modern" (ES6 era, so not brand new) API for making HTTP requests, to replace XMLHttpRequest (the older method that IE pioneered).

It's promise based (thus easier to integrate into code than older callback styles), and designed to give some better options around CORS and handling responses.

> Why it should be in node?

There is a push to adopt some certain "web apis" (APIs that emerged in web browsers) to increase compatibility, reusability and reduce cognitive load when working with both backend and frontend javascript.

Having a common low level call like fetch() means that libraries that are built atop it (SDKs to talk to services, or apply common middleware like JSON:API, oAuth etc) can be shared between node/deno and browsers.

Re:Fetch API has landed into Node.js by golergka on Tuesday February 01, 2022 @10:36AM (#30163913)
Fetch is a popular browser api to download and request stuff from the internet. Having the same api both in browser and in node allows easier re-use of the same application code or libraries on frontend and backend.
Re:Fetch API has landed into Node.js by inglor on Tuesday February 01, 2022 @09:49AM (#30163158)
Re:Fetch API has landed into Node.js by neves on Tuesday February 01, 2022 @09:50AM (#30163176)
It looks like it is a new standard: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

I thought it was a Node popular library.

Re:Fetch API has landed into Node.js by fiddlerwoaroof on Tuesday February 01, 2022 @12:42PM (#30166184)
It’s “new” as of 6 years ago or so.