Fetch API has landed into Node.js

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • node

    Node.js JavaScript runtime ✨🐢🚀✨

  • node-fetch (which is great btw!) implements fetch "reasonably" as in stuff like `fetch('./foo').then(x => x.json())` works but it's very far from a "real" fetch.

    Some people argued users would still like it and there was an attempt[1] by Myles but at the end of the day - the changes were pretty big.

    For example: a response body in fetch is a web stream (a whole new stream type) and to cancel you use an AbortController (web type) which is an EventTarget (another web type). `node-fetch` uses Node streams instead which is very reasonable but not something a platform can "get away" with while still calling it fetch.

    Here is a comment I wrote about it in the tracker during the PR review process https://github.com/nodejs/node/pull/41749#issuecomment-10257...

    [1](https://github.com/nodejs/node/pull/27979)

  • undici

    An HTTP/1.1 client, written from scratch for Node.js

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

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • fetch

    Fetch Standard (by whatwg)

  • This is fetch: https://github.com/whatwg/fetch https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

    Here is discussion about it in Node with some (pretty old) discussion https://docs.google.com/document/d/1tn_-0S_FG_sla81wFohi8Sc8...

  • deno

    A modern runtime for JavaScript and TypeScript.

  • request

    🏊🏾 Simplified HTTP request client.

  • > 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 been a gap in The Right Way to do http requests without going into the low-level API that ‘http(s)’ provides. Fetch is promised-based (enabling seamless async/await) and, most importantly, standardized.

    Basically, fetch provides a meaningful abstraction atop each platforms’ implementation of http-request-doing further unifying server-side and client-side patterns and idioms.

    [0]: https://www.npmjs.com/package/request

  • clipanion

    Type-safe CLI library / framework with no runtime dependencies

  • llhttp

    Port of http_parser to llparse

  • Those wasm blobs are Node's own llhttp https://github.com/nodejs/llhttp in wasm to speed up HTTP parsing.

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

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • gists

    A repo for Backblaze gists used in our FAQ (by Backblaze)

  • Good for NodeJS

    However, I feel the fetch API is completely botched because it lacks timeout support. I have cobbled some together for https://github.com/Backblaze/gists/pull/8 but gosh. I really hope all that is actually not necessary :/

  • got

    🌐 Human-friendly and powerful HTTP request library for Node.js

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

    https://github.com/nodejs/undici/blob/2dd3437e20c5a3cc466226...

    I've argued with the authors of the fetch spec about this before, and ultimately settled on using https://www.npmjs.com/package/set-cookie-parser#user-content... to work around this flaw. (For clarity, I published the package, but chrusart wrote that method - https://github.com/nfriedly/set-cookie-parser/pull/19)

  • create-react-app

    Set up a modern web app by running one command.

  • > 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 is no nice IDE that takes care of doing this part for you compared to other languages (I like to think it akin to starting a project from scratch with C++, gcc, and make).

    Some larger projects, do have scripts that do a lot of boiler plate for you, such as Create-React-App. https://github.com/facebook/create-react-app

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts