Skip to content

Commit 0dfc5c9

Browse files
committed
➖ Remove requirement for abort-controller package in node.js
1 parent aabed5f commit 0dfc5c9

File tree

4 files changed

+3
-40
lines changed

4 files changed

+3
-40
lines changed

README.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -263,22 +263,20 @@ await posts.delete(1).void() // → undefined
263263

264264
### Node.js Support
265265

266-
Install [`node-fetch`](https://github.com/node-fetch/node-fetch), [`abort-controller`](https://github.com/mysticatea/abort-controller) packages and setup them as globally available variables.
266+
Install [`node-fetch`](https://github.com/node-fetch/node-fetch) and setup it as globally available variable.
267267

268268
```sh
269-
yarn add node-fetch abort-controller
269+
npm install --save node-fetch
270270
```
271271

272272
```js
273273
import fetch, { Headers, Request, Response, FormData } from 'node-fetch'
274-
import AbortController from 'abort-controller'
275274

276275
globalThis.fetch = fetch
277276
globalThis.Headers = Headers
278277
globalThis.Request = Request
279278
globalThis.Response = Response
280279
globalThis.FormData = FormData
281-
globalThis.AbortController = AbortController
282280
```
283281

284282
> ⚠️ Please, note `node-fetch` v2 may hang on large response when using `.clone()` or response type shortcuts (like `.json()`) because of smaller buffer size (16 kB). Use v3 instead and override default value of 10mb when needed with [`highWaterMark`](https://github.com/node-fetch/node-fetch#custom-highwatermark) option.
@@ -632,8 +630,7 @@ function void(): Promise<void>
632630
Sets `Accept: '*/*'` in `headers` and returns [`undefined`](http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) after the request:
633631

634632
```ts
635-
await instance.post('/posts', { title: 'Hello' })
636-
// do something
633+
const nothing = await instance.post('/posts', { title: 'Hello' }).void()
637634
```
638635

639636
<details><summary>Same code with native <code>fetch</code></summary>

package-lock.json

-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
"@types/prettier": "^2.7.1",
107107
"@typescript-eslint/eslint-plugin": "^5.42.1",
108108
"@typescript-eslint/parser": "^5.42.1",
109-
"abort-controller": "^3.0.0",
110109
"auto-changelog": "^2.4.0",
111110
"eslint": "^8.27.0",
112111
"eslint-config-prettier": "^8.5.0",

test.setup.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import fetch, { Headers, Request, Response, FormData } from 'node-fetch'
2-
import AbortController from 'abort-controller'
32

43
globalThis.fetch = fetch
54
globalThis.Headers = Headers
65
globalThis.Request = Request
76
globalThis.Response = Response
8-
globalThis.AbortController = AbortController
97
globalThis.FormData = FormData

0 commit comments

Comments
 (0)