{"id":21655245,"url":"https://github.com/pseitz/node-fetch-ts","last_synced_at":"2026-05-20T04:47:31.486Z","repository":{"id":66217886,"uuid":"232176261","full_name":"PSeitz/node-fetch-ts","owner":"PSeitz","description":"typescript implementation of node-fetch","archived":false,"fork":false,"pushed_at":"2020-03-30T19:04:50.000Z","size":164,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-25T06:25:35.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PSeitz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":"node-fetch","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-01-06T20:05:32.000Z","updated_at":"2020-03-30T19:04:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"78cf0d28-9f09-4247-84cb-2d1f988837f1","html_url":"https://github.com/PSeitz/node-fetch-ts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Fnode-fetch-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Fnode-fetch-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Fnode-fetch-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Fnode-fetch-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PSeitz","download_url":"https://codeload.github.com/PSeitz/node-fetch-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244554122,"owners_count":20471173,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T08:31:00.794Z","updated_at":"2026-05-20T04:47:26.465Z","avatar_url":"https://github.com/PSeitz.png","language":"TypeScript","funding_links":["https://opencollective.com/node-fetch"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"docs/media/Banner.svg\" alt=\"Node Fetch\"/\u003e\n  \u003cbr\u003e\n  \u003cp\u003eA light-weight module that brings \u003ccode\u003ewindow.fetch\u003c/code\u003e to Node.js.\u003c/p\u003e\n\u003c/div\u003e\n\n[![build status][travis-image]][travis-url]\n[![coverage status][codecov-image]][codecov-url]\n[![install size][install-size-image]][install-size-url]\n[![Discord][discord-image]][discord-url]\n\n[![NPM](https://nodei.co/npm/node-fetch.png)](https://nodei.co/npm/node-fetch/)\n\n**Consider supporting us on our Open Collective:**\n\n[![Donate to our collective][opencollective-image]][opencollective-url]\n\n---\n\n\u003c!-- TOC --\u003e\n\n- [Motivation](#motivation)\n- [Features](#features)\n- [Difference from client-side fetch](#difference-from-client-side-fetch)\n- [Installation](#installation)\n- [Loading and configuring the module](#loading-and-configuring-the-module)\n- [Upgrading](#upgrading)\n- [Common Usage](#common-usage)\n    - [Plain text or HTML](#plain-text-or-html)\n    - [JSON](#json)\n    - [Simple Post](#simple-post)\n    - [Post with JSON](#post-with-json)\n    - [Post with form parameters](#post-with-form-parameters)\n    - [Handling exceptions](#handling-exceptions)\n    - [Handling client and server errors](#handling-client-and-server-errors)\n- [Advanced Usage](#advanced-usage)\n    - [Streams](#streams)\n    - [Buffer](#buffer)\n    - [Accessing Headers and other Meta data](#accessing-headers-and-other-meta-data)\n    - [Extract Set-Cookie Header](#extract-set-cookie-header)\n    - [Post data using a file stream](#post-data-using-a-file-stream)\n    - [Post with form-data (detect multipart)](#post-with-form-data-detect-multipart)\n    - [Request cancellation with AbortSignal](#request-cancellation-with-abortsignal)\n- [API](#api)\n    - [fetch(url[, options])](#fetchurl-options)\n    - [Options](#options)\n        - [Default Headers](#default-headers)\n        - [Custom Agent](#custom-agent)\n        - [Custom highWaterMark](#custom-highwatermark)\n    - [Class: Request](#class-request)\n        - [new Request(input[, options])](#new-requestinput-options)\n    - [Class: Response](#class-response)\n        - [new Response([body[, options]])](#new-responsebody-options)\n        - [response.ok](#responseok)\n        - [response.redirected](#responseredirected)\n    - [Class: Headers](#class-headers)\n        - [new Headers([init])](#new-headersinit)\n    - [Interface: Body](#interface-body)\n        - [body.body](#bodybody)\n        - [body.bodyUsed](#bodybodyused)\n        - [body.arrayBuffer()](#bodyarraybuffer)\n        - [body.blob()](#bodyblob)\n        - [body.json()](#bodyjson)\n        - [body.text()](#bodytext)\n        - [body.buffer()](#bodybuffer)\n    - [Class: FetchError](#class-fetcherror)\n    - [Class: AbortError](#class-aborterror)\n- [TypeScript](#typescript)\n- [Acknowledgement](#acknowledgement)\n- [Team](#team)\n                - [Former](#former)\n- [License](#license)\n\n\u003c!-- /TOC --\u003e\n\n## Motivation\n\nInstead of implementing `XMLHttpRequest` in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native `http` to `fetch` API directly? Hence `node-fetch`, minimal code for a `window.fetch` compatible API on Node.js runtime.\n\nSee Matt Andrews' [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) or Leonardo Quixada's [cross-fetch](https://github.com/lquixada/cross-fetch) for isomorphic usage (exports `node-fetch` for server-side, `whatwg-fetch` for client-side).\n\n## Features\n\n- Stay consistent with `window.fetch` API.\n- Make conscious trade-off when following [WHATWG fetch spec][whatwg-fetch] and [stream spec](https://streams.spec.whatwg.org/) implementation details, document known differences.\n- Use native Node streams for body, on both request and response.\n- Decode content encoding (gzip/deflate) properly, and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically.\n- Useful extensions such as timeout, redirect limit, response size limit, [explicit errors][error-handling.md] for troubleshooting.\n\n## Difference from client-side fetch\n\n- See known differences:\n\t- [As of v3.x](docs/v3-LIMITS.md)\n\t- [As of v2.x](docs/v2-LIMITS.md)\n- If you happen to use a missing feature that `window.fetch` offers, feel free to open an issue.\n- Pull requests are welcomed too!\n\n## Installation\n\nCurrent stable release (`3.x`)\n\n```sh\n$ npm install node-fetch\n```\n\n## Loading and configuring the module\n\nWe suggest you load the module via `require`, pending the stabalizing of es modules in node:\n\n```js\nconst fetch = require('node-fetch');\n```\n\nIf you are using a Promise library other than native, set it through `fetch.Promise`:\n\n```js\nconst fetch = require('node-fetch');\nconst Bluebird = require('bluebird');\n\nfetch.Promise = Bluebird;\n```\n\nIf you want to patch the global object in node:\n\n```js\nconst fetch = require('node-fetch');\n\nif (!globalThis.fetch) {\n    globalThis.fetch = fetch;\n}\n```\n\nFor versions of node earlier than 12.x, use this `globalThis` [polyfill](https://mathiasbynens.be/notes/globalthis):\n\n```js\n(function() {\n\tif (typeof globalThis === 'object') return;\n\tObject.defineProperty(Object.prototype, '__magic__', {\n\t\tget: function() {\n\t\t\treturn this;\n\t\t},\n\t\tconfigurable: true\n\t});\n\t__magic__.globalThis = __magic__;\n\tdelete Object.prototype.__magic__;\n}());\n```\n\n## Common Usage\n\nNOTE: The documentation below is up-to-date with `3.x` releases, if you are using an older version, please check how to [upgrade](#upgrading).\n\n### Plain text or HTML\n\n```js\nconst fetch = require('node-fetch-ts');\n\nfetch('https://github.com/')\n\t.then(res =\u003e res.text())\n\t.then(body =\u003e console.log(body));\n```\n\n### JSON\n\n```js\nconst fetch = require('node-fetch-ts');\n\nfetch('https://api.github.com/users/github')\n\t.then(res =\u003e res.json())\n\t.then(json =\u003e console.log(json));\n```\n\n### Simple Post\n\n```js\nconst fetch = require('node-fetch-ts');\n\nfetch('https://httpbin.org/post', {method: 'POST', body: 'a=1'})\n\t.then(res =\u003e res.json()) // expecting a json response\n\t.then(json =\u003e console.log(json));\n```\n\n### Post with JSON\n\n```js\nconst fetch = require('node-fetch-ts');\n\nconst body = {a: 1};\n\nfetch('https://httpbin.org/post', {\n\tmethod: 'post',\n\tbody: JSON.stringify(body),\n\theaders: {'Content-Type': 'application/json'}\n})\n\t.then(res =\u003e res.json())\n\t.then(json =\u003e console.log(json));\n```\n\n### Post with form parameters\n\n`URLSearchParams` is available on the global object in Node.js as of v10.0.0. See [official documentation](https://nodejs.org/api/url.html#url_class_urlsearchparams) for more usage methods.\n\nNOTE: The `Content-Type` header is only set automatically to `x-www-form-urlencoded` when an instance of `URLSearchParams` is given as such:\n\n```js\nconst fetch = require('node-fetch-ts');\n\nconst params = new URLSearchParams();\nparams.append('a', 1);\n\nfetch('https://httpbin.org/post', {method: 'POST', body: params})\n\t.then(res =\u003e res.json())\n\t.then(json =\u003e console.log(json));\n```\n\n### Handling exceptions\n\nNOTE: 3xx-5xx responses are _NOT_ exceptions, and should be handled in `then()`, see the next section.\n\nAdding a catch to the fetch promise chain will catch _all_ exceptions, such as errors originating from node core libraries, like network errors, and operational errors which are instances of FetchError. See the [error handling document][error-handling.md] for more details.\n\n```js\nconst fetch = require('node-fetch-ts');\n\nfetch('https://domain.invalid/').catch(err =\u003e console.error(err));\n```\n\n### Handling client and server errors\n\nIt is common to create a helper function to check that the response contains no client (4xx) or server (5xx) error responses:\n\n```js\nconst fetch = require('node-fetch-ts');\n\nfunction checkStatus(res) {\n\tif (res.ok) {\n\t\t// res.status \u003e= 200 \u0026\u0026 res.status \u003c 300\n\t\treturn res;\n\t} else {\n\t\tthrow MyCustomError(res.statusText);\n\t}\n}\n\nfetch('https://httpbin.org/status/400')\n\t.then(checkStatus)\n\t.then(res =\u003e console.log('will not get here...'));\n```\n\n## Advanced Usage\n\n### Streams\n\nThe \"Node.js way\" is to use streams when possible:\n\n```js\nconst {createWriteStream} = require('fs');\nconst fetch = require('node-fetch-ts');\n\nfetch(\n\t'https://octodex.github.com/images/Fintechtocat.png'\n).then(res =\u003e {\n\tconst dest = fs.createWriteStream('./octocat.png');\n\tres.body.pipe(dest);\n});\n```\n\n### Buffer\n\nIf you prefer to cache binary data in full, use buffer(). (NOTE: buffer() is a `node-fetch-ts` only API)\n\n```js\nconst fetch = require('node-fetch-ts');\nconst fileType = require('file-type');\n\nfetch('https://octodex.github.com/images/Fintechtocat.png')\n\t.then(res =\u003e res.buffer())\n\t.then(buffer =\u003e fileType(buffer))\n\t.then(type =\u003e {\n\t\tconsole.log(type);\n\t});\n```\n\n### Accessing Headers and other Meta data\n\n```js\nconst fetch = require('node-fetch-ts');\n\nfetch('https://github.com/').then(res =\u003e {\n\tconsole.log(res.ok);\n\tconsole.log(res.status);\n\tconsole.log(res.statusText);\n\tconsole.log(res.headers.raw());\n\tconsole.log(res.headers.get('content-type'));\n});\n```\n\n### Extract Set-Cookie Header\n\nUnlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.raw()`, this is a `node-fetch-ts` only API.\n\n```js\nconst fetch = require('node-fetch-ts');\n\nfetch('https://example.com').then(res =\u003e {\n\t// returns an array of values, instead of a string of comma-separated values\n\tconsole.log(res.headers.raw()['set-cookie']);\n});\n```\n\n### Post data using a file stream\n\n```js\nconst {createReadStream} = require('fs');\nconst fetch = require('node-fetch-ts');\n\nconst stream = createReadStream('input.txt');\n\nfetch('https://httpbin.org/post', {method: 'POST', body: stream})\n\t.then(res =\u003e res.json())\n\t.then(json =\u003e console.log(json));\n```\n\n### Post with form-data (detect multipart)\n\n```js\nconst fetch = require('node-fetch-ts');\nconst FormData = require('form-data');\n\nconst form = new FormData();\nform.append('a', 1);\n\nfetch('https://httpbin.org/post', {method: 'POST', body: form})\n\t.then(res =\u003e res.json())\n\t.then(json =\u003e console.log(json));\n\n// OR, using custom headers\n// NOTE: getHeaders() is non-standard API\n\nconst options = {\n\tmethod: 'POST',\n\tbody: form,\n\theaders: form.getHeaders()\n};\n\nfetch('https://httpbin.org/post', options)\n\t.then(res =\u003e res.json())\n\t.then(json =\u003e console.log(json));\n```\n\n### Request cancellation with AbortSignal\n\nYou may cancel requests with `AbortController`. A suggested implementation is [`abort-controller`](https://www.npmjs.com/package/abort-controller).\n\nAn example of timing out a request after 150ms could be achieved as follows:\n\n```js\nconst fetch = require('node-fetch-ts');\nconst AbortController = require('abort-controller');\n\nconst controller = new AbortController();\nconst timeout = setTimeout(() =\u003e {\n\tcontroller.abort();\n}, 150);\n\nfetch('https://example.com', {signal: controller.signal})\n\t.then(res =\u003e res.json())\n\t.then(\n\t\tdata =\u003e {\n\t\t\tuseData(data);\n\t\t},\n\t\terr =\u003e {\n\t\t\tif (err.name === 'AbortError') {\n                console.log('request was aborted');\n\t\t\t}\n\t\t}\n\t)\n\t.finally(() =\u003e {\n\t\tclearTimeout(timeout);\n\t});\n```\n\nSee [test cases](https://github.com/node-fetch/node-fetch/blob/master/test/test.js) for more examples.\n\n## API\n\n### fetch(url[, options])\n\n- `url` A string representing the URL for fetching\n- `options` [Options](#fetch-options) for the HTTP(S) request\n- Returns: \u003ccode\u003ePromise\u0026lt;[Response](#class-response)\u0026gt;\u003c/code\u003e\n\nPerform an HTTP(S) fetch.\n\n`url` should be an absolute url, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected promise.\n\n\u003ca id=\"fetch-options\"\u003e\u003c/a\u003e\n\n### Options\n\nThe default values are shown after each option key.\n\n```js\n{\n    // These properties are part of the Fetch Standard\n    method: 'GET',\n    headers: {},            // request headers. format is the identical to that accepted by the Headers constructor (see below)\n    body: null,             // request body. can be null, a string, a Buffer, a Blob, or a Node.js Readable stream\n    redirect: 'follow',     // set to `manual` to extract redirect headers, `error` to reject redirect\n    signal: null,           // pass an instance of AbortSignal to optionally abort requests\n\n    // The following properties are node-fetch extensions\n    follow: 20,             // maximum redirect count. 0 to not follow redirect\n    timeout: 0,             // req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies). Signal is recommended instead.\n    compress: true,         // support gzip/deflate content encoding. false to disable\n    size: 0,                // maximum response body size in bytes. 0 to disable\n    agent: null             // http(s).Agent instance or function that returns an instance (see below)\n    highWaterMark: 16384    // the maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource.\n}\n```\n\n#### Default Headers\n\nIf no values are set, the following request headers will be sent automatically:\n\n| Header              | Value                                                    |\n| ------------------- | -------------------------------------------------------- |\n| `Accept-Encoding`   | `gzip,deflate` _(when `options.compress === true`)_      |\n| `Accept`            | `*/*`                                                    |\n| `Connection`        | `close` _(when no `options.agent` is present)_           |\n| `Content-Length`    | _(automatically calculated, if possible)_                |\n| `Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_                |\n| `User-Agent`        | `node-fetch (+https://github.com/node-fetch/node-fetch)` |\n\nNote: when `body` is a `Stream`, `Content-Length` is not set automatically.\n\n#### Custom Agent\n\nThe `agent` option allows you to specify networking related options that's out of the scope of Fetch. Including and not limit to:\n\n- Support self-signed certificate\n- Use only IPv4 or IPv6\n- Custom DNS Lookup\n\nSee [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options) for more information.\n\nIn addition, `agent` option accepts a function that returns http(s).Agent instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol.\n\n```js\nconst http = require('http');\nconst https = require('https');\n\nconst httpAgent = new http.Agent({\n\tkeepAlive: true\n});\nconst httpsAgent = new https.Agent({\n\tkeepAlive: true\n});\n\nconst options = {\n\tagent: function(_parsedURL) {\n\t\tif (_parsedURL.protocol == 'http:') {\n\t\t\treturn httpAgent;\n\t\t} else {\n\t\t\treturn httpsAgent;\n\t\t}\n\t}\n};\n```\n\n\u003ca id=\"custom-highWaterMark\"\u003e\u003c/a\u003e\n\n#### Custom highWaterMark\n\nStream on Node.js have a smaller internal buffer size (16Kb, aka `highWaterMark`) from client-side browsers (\u003e1Mb, not consistent across browsers). Because of that, when you are writing an isomorphic app and using `res.clone()`, it will hang with large response in Node.\n\nThe recommended way to fix this problem is to resolve cloned response in parallel:\n\n```js\nconst fetch = require('node-fetch');\n\nfetch('https://example.com').then(res =\u003e {\n\tconst r1 = res.clone();\n\n\treturn Promise.all([res.json(), r1.text()]).then(results =\u003e {\n\t\tconsole.log(results[0]);\n\t\tconsole.log(results[1]);\n\t});\n});\n```\n\nIf for some reason you don't like the solution above, since `3.x` you are able to modify the `highWaterMark` option:\n\n```js\nconst fetch = require('node-fetch');\n\nfetch('https://example.com', {highWaterMark: 10}).then(res =\u003e res.clone().buffer());\n```\n\n\u003ca id=\"class-request\"\u003e\u003c/a\u003e\n\n### Class: Request\n\nAn HTTP(S) request containing information about URL, method, headers, and the body. This class implements the [Body](#iface-body) interface.\n\nDue to the nature of Node.js, the following properties are not implemented at this moment:\n\n- `type`\n- `destination`\n- `referrer`\n- `referrerPolicy`\n- `mode`\n- `credentials`\n- `cache`\n- `integrity`\n- `keepalive`\n\nThe following node-fetch extension properties are provided:\n\n- `follow`\n- `compress`\n- `counter`\n- `agent`\n- `highWaterMark`\n\nSee [options](#fetch-options) for exact meaning of these extensions.\n\n#### new Request(input[, options])\n\n\u003csmall\u003e_(spec-compliant)_\u003c/small\u003e\n\n- `input` A string representing a URL, or another `Request` (which will be cloned)\n- `options` [Options][#fetch-options] for the HTTP(S) request\n\nConstructs a new `Request` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request).\n\nIn most cases, directly `fetch(url, options)` is simpler than creating a `Request` object.\n\n\u003ca id=\"class-response\"\u003e\u003c/a\u003e\n\n### Class: Response\n\nAn HTTP(S) response. This class implements the [Body](#iface-body) interface.\n\nThe following properties are not implemented in node-fetch at this moment:\n\n- `Response.error()`\n- `Response.redirect()`\n- `type`\n- `trailer`\n\n#### new Response([body[, options]])\n\n\u003csmall\u003e_(spec-compliant)_\u003c/small\u003e\n\n- `body` A string or [Readable stream][node-readable]\n- `options` A [`ResponseInit`][response-init] options dictionary\n\nConstructs a new `Response` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response).\n\nBecause Node.js does not implement service workers (for which this class was designed), one rarely has to construct a `Response` directly.\n\n#### response.ok\n\n\u003csmall\u003e_(spec-compliant)_\u003c/small\u003e\n\nConvenience property representing if the request ended normally. Will evaluate to true if the response status was greater than or equal to 200 but smaller than 300.\n\n#### response.redirected\n\n\u003csmall\u003e_(spec-compliant)_\u003c/small\u003e\n\nConvenience property representing if the request has been redirected at least once. Will evaluate to true if the internal redirect counter is greater than 0.\n\n\u003ca id=\"class-headers\"\u003e\u003c/a\u003e\n\n### Class: Headers\n\nThis class allows manipulating and iterating over a set of HTTP headers. All methods specified in the [Fetch Standard][whatwg-fetch] are implemented.\n\n#### new Headers([init])\n\n\u003csmall\u003e_(spec-compliant)_\u003c/small\u003e\n\n- `init` Optional argument to pre-fill the `Headers` object\n\nConstruct a new `Headers` object. `init` can be either `null`, a `Headers` object, an key-value map object, or any iterable object.\n\n```js\n// Example adapted from https://fetch.spec.whatwg.org/#example-headers-class\nconst Headers = require('node-fetch');\n\nconst meta = {\n\t'Content-Type': 'text/xml',\n\t'Breaking-Bad': '\u003c3'\n};\nconst headers = new Headers(meta);\n\n// The above is equivalent to\nconst meta = [['Content-Type', 'text/xml'], ['Breaking-Bad', '\u003c3']];\nconst headers = new Headers(meta);\n\n// You can in fact use any iterable objects, like a Map or even another Headers\nconst meta = new Map();\nmeta.set('Content-Type', 'text/xml');\nmeta.set('Breaking-Bad', '\u003c3');\nconst headers = new Headers(meta);\nconst copyOfHeaders = new Headers(headers);\n```\n\n\u003ca id=\"iface-body\"\u003e\u003c/a\u003e\n\n### Interface: Body\n\n`Body` is an abstract interface with methods that are applicable to both `Request` and `Response` classes.\n\nThe following methods are not yet implemented in node-fetch at this moment:\n\n- `formData()`\n\n#### body.body\n\n\u003csmall\u003e_(deviation from spec)_\u003c/small\u003e\n\n- Node.js [`Readable` stream][node-readable]\n\nThe data encapsulated in the `Body` object. Note that while the [Fetch Standard][whatwg-fetch] requires the property to always be a WHATWG `ReadableStream`, in node-fetch it is a Node.js [`Readable` stream][node-readable].\n\n#### body.bodyUsed\n\n\u003csmall\u003e_(spec-compliant)_\u003c/small\u003e\n\n- `Boolean`\n\nA boolean property for if this body has been consumed. Per spec, a consumed body cannot be used again.\n\n#### body.arrayBuffer()\n\n#### body.blob()\n\n#### body.json()\n\n#### body.text()\n\n\u003csmall\u003e_(spec-compliant)_\u003c/small\u003e\n\n- Returns: `Promise`\n\nConsume the body and return a promise that will resolve to one of these formats.\n\n#### body.buffer()\n\n\u003csmall\u003e_(node-fetch extension)_\u003c/small\u003e\n\n- Returns: `Promise\u003cBuffer\u003e`\n\nConsume the body and return a promise that will resolve to a Buffer.\n\n\u003ca id=\"class-fetcherror\"\u003e\u003c/a\u003e\n\n### Class: FetchError\n\n\u003csmall\u003e_(node-fetch extension)_\u003c/small\u003e\n\nAn operational error in the fetching process. See [ERROR-HANDLING.md][] for more info.\n\n\u003ca id=\"class-aborterror\"\u003e\u003c/a\u003e\n\n### Class: AbortError\n\n\u003csmall\u003e_(node-fetch extension)_\u003c/small\u003e\n\nAn Error thrown when the request is aborted in response to an `AbortSignal`'s `abort` event. It has a `name` property of `AbortError`. See [ERROR-HANDLING.MD][] for more info.\n\n## TypeScript\n\nSince `3.x` types are bundled with `node-fetch`, so you don't need to install any additional packages.\n\nFor older versions please use the type definitions from [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped):\n\n```sh\n$ npm install --save-dev @types/node-fetch\n```\n\n## Acknowledgement\n\nThanks to [github/fetch](https://github.com/github/fetch) for providing a solid implementation reference.\n\n## Team\n\n[![David Frank](https://github.com/bitinn.png?size=100)](https://github.com/bitinn) | [![Jimmy Wärting](https://github.com/jimmywarting.png?size=100)](https://github.com/jimmywarting) | [![Antoni Kepinski](https://github.com/xxczaki.png?size=100)](https://github.com/xxczaki) | [![Richie Bendall](https://github.com/Richienb.png?size=100)](https://github.com/Richienb) | [![Gregor Martynus](https://github.com/gr2m.png?size=100)](https://github.com/gr2m)\n---|---|---|---|---\n[David Frank](https://bitinn.net/) | [Jimmy Wärting](https://jimmy.warting.se/) | [Antoni Kepinski](https://kepinski.me) | [Richie Bendall](https://www.richie-bendall.ml/) | [Gregor Martynus](https://twitter.com/gr2m)\n\n###### Former\n\n- [Timothy Gu](https://github.com/timothygu)\n- [Jared Kantrowitz](https://github.com/jkantr)\n\n## License\n\nMIT\n\n[travis-image]: https://img.shields.io/travis/com/node-fetch/node-fetch/master?style=flat-square\n[travis-url]: https://travis-ci.com/node-fetch/node-fetch\n[codecov-image]: https://img.shields.io/codecov/c/gh/node-fetch/node-fetch/master?style=flat-square\n[codecov-url]: https://codecov.io/gh/node-fetch/node-fetch\n[opencollective-image]: https://opencollective.com/node-fetch/donate/button.png?color=blue\n[opencollective-url]: https://opencollective.com/node-fetch\n[install-size-image]: https://flat.badgen.net/packagephobia/install/node-fetch\n[install-size-url]: https://packagephobia.now.sh/result?p=node-fetch\n[discord-image]: https://img.shields.io/discord/619915844268326952?color=%237289DA\u0026label=Discord\u0026style=flat-square\n[discord-url]: https://discord.gg/Zxbndcm\n[whatwg-fetch]: https://fetch.spec.whatwg.org/\n[response-init]: https://fetch.spec.whatwg.org/#responseinit\n[node-readable]: https://nodejs.org/api/stream.html#stream_readable_streams\n[mdn-headers]: https://developer.mozilla.org/en-US/docs/Web/API/Headers\n[error-handling.md]: https://github.com/node-fetch/node-fetch/blob/master/docs/ERROR-HANDLING.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseitz%2Fnode-fetch-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpseitz%2Fnode-fetch-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseitz%2Fnode-fetch-ts/lists"}