You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR-URL: #42939
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
_Note: Once a mixin has been called then the body cannot be reused, thus calling additional mixins on `.body`, e.g. `.body.json(); .body.text()` will result in an error `TypeError: unusable` being thrown and returned through the `Promise` rejection._
95
+
96
+
Should you need to access the `body` in plain-text after using a mixin, the best practice is to use the `.text()` mixin first and then manually parse the text to the desired format.
97
+
98
+
For more information about their behavior, please reference the body mixin from the [Fetch Standard](https://fetch.spec.whatwg.org/#body-mixin).
99
+
86
100
## Common API Methods
87
101
88
102
This section documents our most commonly used API methods. Additional APIs are documented in their own files within the [docs](./docs/) folder and are accessible via the navigation list on the left side of the docs site.
@@ -213,7 +227,7 @@ const data = {
213
227
214
228
#### `response.body`
215
229
216
-
Nodejs has two kinds of streams: [web streams](https://nodejs.org/dist/latest-v16.x/docs/api/webstreams.html) which follow the API of the WHATWG web standard found in browsers, and an older Node-specific [streams API](https://nodejs.org/api/stream.html). `response.body` returns a readable web stream. If you would prefer to work with a Node stream you can convert a web stream using `.fromWeb()`.
230
+
Nodejs has two kinds of streams: [web streams](https://nodejs.org/dist/latest-v16.x/docs/api/webstreams.html), which follow the API of the WHATWG web standard found in browsers, and an older Node-specific [streams API](https://nodejs.org/api/stream.html). `response.body` returns a readable web stream. If you would prefer to work with a Node stream you can convert a web stream using `.fromWeb()`.
217
231
218
232
```js
219
233
import {fetch} from'undici';
@@ -228,7 +242,7 @@ Nodejs has two kinds of streams: [web streams](https://nodejs.org/dist/latest-v1
228
242
229
243
#### Specification Compliance
230
244
231
-
This section documents parts of the [Fetch Standard](https://fetch.spec.whatwg.org)which Undici does
245
+
This section documents parts of the [Fetch Standard](https://fetch.spec.whatwg.org)that Undici does
232
246
not support or does not fully implement.
233
247
234
248
##### Garbage Collection
@@ -239,7 +253,7 @@ The [Fetch Standard](https://fetch.spec.whatwg.org) allows users to skip consumi
239
253
[garbage collection](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management#garbage_collection) to release connection resources. Undici does not do the same. Therefore, it is important to always either consume or cancel the response body.
240
254
241
255
Garbage collection in Node is less aggressive and deterministic
242
-
(due to the lack of clear idle periods that browser have through the rendering refresh rate)
256
+
(due to the lack of clear idle periods that browsers have through the rendering refresh rate)
243
257
which means that leaving the release of connection resources to the garbage collector can lead
244
258
to excessive connection usage, reduced performance (due to less connection re-use), and even
245
259
stalls or deadlocks when running out of connections.
@@ -301,7 +315,7 @@ Returns: `Dispatcher`
301
315
302
316
## Specification Compliance
303
317
304
-
This section documents parts of the HTTP/1.1 specification which Undici does
318
+
This section documents parts of the HTTP/1.1 specification that Undici does
305
319
not support or does not fully implement.
306
320
307
321
### Expect
@@ -334,7 +348,7 @@ aborted.
334
348
335
349
### Manual Redirect
336
350
337
-
Since it is not possible to manually follow an HTTP redirect on server-side,
351
+
Since it is not possible to manually follow an HTTP redirect on the server-side,
338
352
Undici returns the actual response instead of an `opaqueredirect` filtered one
339
353
when invoked with a `manual` redirect. This aligns `fetch()` with the other
***idempotent**`boolean` (optional) - Default: `true` if `method` is `'HEAD'` or `'GET'` - Whether the requests can be safely retried or not. If `false` the request won't be sent until all preceding requests in the pipeline has completed.
198
198
***blocking**`boolean` (optional) - Default: `false` - Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received.
199
199
***upgrade**`string | null` (optional) - Default: `null` - Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`.
0 commit comments