FYI - Fetch API in NodeJs 17

Hi folks,

This is not a question, but just something I thought that might be of interest to some developers in this community.

Some time ago the Http-Request node has been refactored completely, because it was build on top of the request library which had become obsolete. Currently it is based on the well maintained got library.

But it seems that meanwhile the NodeJs core team has also been following the whole 'request' library problem, and as a result they have finally implemented the Fetch API. See this article:

Inbuilt Fetch for Node.js might mean the end for packages like node-fetch, got, cross-fetch, and many others that were built for the same purpose.

However it is not usable at this moment yet for Node-RED node developers:

  • Minimum NodeJs version 17 is required (while Node-RED supports older NodeJs versions).
  • In the article you find some limitations/drawbacks of the current Fetch implementation.

But it might become useful for some of us in the future...



Yes, well worth keeping an eye on the node.js versions because big changes are making their way through the sausage machine.

My understanding is that v14 introduced: optional chaining, Nullish Coalescing operators, String.prototype.matchAll, Intl.DisplayNames, Intl.DateTimeFormat, WeakReferences, private class methods. And experimental: Async Local Storage, Top-Level Await, Diagnostic report

v15/6 introduces: logical assignment operators, String.prototype.replaceAll, Promise.any, AggregateError, AbortController, Promisified setTimeout/setImmediate

v18 introduces: findLast() and findLastIndex() array methods, more Intl updates, improved performance of class fields and private class methods, Core test runner module. Experimental Webstream API, Fetch of course.

So worth remembering that Fetch will only be experimental in v18 until it is fully ratified so I'd expect it to become final sometime during the v18 releases unless it takes a long time, in which case it won't become fully settled until v20.

Also worth remembering that gives loads of detailed information about what features are available in which specific node.js version.

1 Like

Pretty sure private class methods are in node,js 12+ (I use them in v16 anyhow :slight_smile: )

I believe they arrived after v14.5

Node.js ES2015/ES6, ES2016 and ES2017 support

Which is why I haven't yet used them in uibuilder as I haven't release a v14 compatible version yet thanks to a broken thumb over the summer :frowning:

Oh, also why the automated quality reviews for nodes are a bit annoying since they penalise you if you don't have exactly the same node.js engine dependency as node-red but actually, you might (and I do) want a minor release difference in uibuilder.

1 Like

FWIW – Node-RED MCU Edition is already using fetch. Check out our implementation of the core HTTP Request Node to see how it is used there. The MCU port of the OpenWeatherMap Node also uses fetch and it only took a few minutes to make the changes.

It would be great to have more Node-RED nodes using fetch as it should make also running them on an MCU easier. Because of backwards compatibility that may take some time, but aligning on standards like fetch in the long-term seems like a good direction.


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.