For the past months, we have been working hard on a new release of node-fetch, a light-weight module that brings window.fetch to Node.js. Today we are thrilled to announce the first v3 beta release.

What’s new?

Here is a brief list of changes, which we are most excited about:

Minimum supported Node.js version is now 10

Since Node.js will deprecate version 8 at the end of 2019, we decided that node-fetch v3.x will not only drop support for Node.js 4 and 6 (which were supported in v2.x), but also for Node.js 8. We strongly encourage you to upgrade, if you still haven’t done so. Check out Node.js’ official LTS plan for more information on Node.js’ support lifetime.

Response.statusText no longer sets a default message derived from the HTTP status code

If the server didn’t respond with status text, node-fetch would set a default message derived from the HTTP status code. This behavior was not spec-compliant and now the statusText will remain blank instead.

Dropped the browser field in package.json

Prior to v3.x, we included a browser field in the package.json file. Since node-fetch is intended to be used on the server, we have removed this field. If you are using node-fetch client-side, consider switching to something like cross-fetch.

Dropped the res.textConverted() function

If you want charset encoding detection, please use the fetch-charset-detection package (documentation):

Data URI support

Previously, node-fetch only supported HTTP URL scheme. However, the Fetch Standard recently introduced the data: URI support. Following the specification, we implemented this feature in v3.x. Read more about data: URLs here.

New & exposed Blob implementation

Blob implementation is now fetch-blob and hence is exposed, unlikely previously, where Blob type was only internal and not exported.

Better UTF-8 URL handling

We now use the new Node.js WHATWG-compliant URL API, so UTF-8 URLs are handled properly.

New node-fetch-only option: highWaterMark

If you are using res.clone() and writing an isomorphic app, note that stream on Node.js has a smaller internal buffer size (16Kb, aka highWaterMark ) from client-side browsers (>1Mb, not consistent across browsers). Learn how to get around this.

The recommended way to fix this problem is to resolve the cloned response in parallel:

However, if for some reason you don’t like the solution above, since 3.x you are able to modify the highWaterMark option:

The new release also includes many other changes, some of which might require you to update your code. Check out the following resources to learn more:

How do I try it?

Since this is a beta release, you can install it from npm using the following command:

$ npm install node-fetch@next

Please report any issues on our Github repo.

Funding

If you and/or your company is using node-fetch, consider supporting our project on Open Collective. Financial support will help us stay motivated and continue to improve the project with each and new release!