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
This is [experimental](https://nodejs.org/api/documentation.html#documentation_stability_index) and is not yet fully compliant with the Fetch Standard.
182
182
We plan to ship breaking changes to this feature until it is out of experimental.
However, if you want to get only headers, it might be better to use `HEAD` request method. Usage of this method will obviate the need for consumption or cancelling of the response body. See [MDN - HTTP - HTTP request methods - HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) for more details.
***onInfo**`({statusCode: number, headers: Record<string, string | string[]>}) => void | null` (optional) - Default: `null` - Callback collecting all the info headers (HTTP 100-199) received.
473
473
474
474
The `RequestOptions.method` property should not be value `'CONNECT'`.
475
475
476
476
#### Parameter: `ResponseData`
477
477
478
478
***statusCode**`number`
479
-
***headers**`http.IncomingHttpHeaders`
479
+
***headers**`http.IncomingHttpHeaders` - Note that all header keys are lower-cased, e. g. `content-type`.
480
480
***body**`stream.Readable` which also implements [the body mixin from the Fetch Standard](https://fetch.spec.whatwg.org/#body-mixin).
481
481
***trailers**`Record<string, string>` - This object starts out
482
482
as empty and will be mutated to contain trailers after `body` has emitted `'end'`.
@@ -497,6 +497,8 @@ The `RequestOptions.method` property should not be value `'CONNECT'`.
497
497
498
498
-`dump({ limit: Integer })`, dump the response by reading up to `limit` bytes without killing the socket (optional) - Default: 262144.
499
499
500
+
Note that body will still be a `Readable` even if it is empty, but attempting to deserialize it with `json()` will result in an exception. Recommended way to ensure there is a body to deserialize is to check if status code is not 204, and `content-type` header starts with `application/json`.
0 commit comments