# FYI - Fetch API in NodeJs 17

**URL:** https://discourse.nodered.org/t/fyi-fetch-api-in-nodejs-17/69025
**Category:** Developing Nodes
**Created:** [14 October 2022 10:37 UTC](https://discourse.nodered.org/t/fyi-fetch-api-in-nodejs-17/69025 "2022-10-14T10:37:00Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [14 October 2022 10:37 UTC](https://discourse.nodered.org/t/fyi-fetch-api-in-nodejs-17/69025/1 "2022-10-14T10:37:00Z")

</div>

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](https://www.npmjs.com/package/request) library which had become obsolete. Currently it is based on the well maintained [got](https://www.npmjs.com/package/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](https://blog.logrocket.com/fetch-api-node-js/) 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](https://nodered.org/docs/faq/node-versions) 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...

Bart

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [14 October 2022 12:48 UTC](https://discourse.nodered.org/t/fyi-fetch-api-in-nodejs-17/69025/2 "2022-10-14T12:48:14Z")

</div>

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 [https://node.green/](https://node.green/) gives loads of detailed information about what features are available in which specific node.js version.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [14 October 2022 12:53 UTC](https://discourse.nodered.org/t/fyi-fetch-api-in-nodejs-17/69025/3 "2022-10-14T12:53:19Z")

</div>

> [@TotallyInformation](#):
>
> private class methods

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

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [14 October 2022 12:56 UTC](https://discourse.nodered.org/t/fyi-fetch-api-in-nodejs-17/69025/4 "2022-10-14T12:56:24Z")

</div>

> [@Steve-Mcl](#):
>
> Pretty sure private class methods are in node,js 12+

I believe they arrived after v14.5

[Node.js ES2015/ES6, ES2016 and ES2017 support](https://node.green/#ES2022-features-private-class-methods)

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 ☹

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.

---

<div class="post-metadata">

### Author: ![phoddie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/phoddie/32/64232_2.png) [@phoddie](https://discourse.nodered.org/u/phoddie)
#### Post date: [18 October 2022 16:29 UTC](https://discourse.nodered.org/t/fyi-fetch-api-in-nodejs-17/69025/5 "2022-10-18T16:29:14Z")

</div>

FWIW – Node-RED MCU Edition is already using `fetch`. Check out [our implementation](https://github.com/phoddie/node-red-mcu/blob/main/nodes/httprequest/httprequest.js) of the core HTTP Request Node to see how it is used there. The [MCU port of the OpenWeatherMap](https://github.com/phoddie/node-red-mcu/blob/main/nodes/openweathermap/weather.js) 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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [17 December 2022 16:30 UTC](https://discourse.nodered.org/t/fyi-fetch-api-in-nodejs-17/69025/6 "2022-12-17T16:30:07Z")

</div>

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