From 0ab830b2cfcedea8df36883fd771285912b6b16d Mon Sep 17 00:00:00 2001 From: zizifn <515868058@qq.com> Date: Fri, 25 Nov 2022 16:56:12 +0800 Subject: [PATCH] chore(doc/fetch) update doc for fetch duplex (#1760) (#1765) * chore(doc/fetch) update doc for fetch duplex (#1760) * chore(doc/fetch) update doc for fetch duplex (#1760) --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2cdaa045b1e..bd991008a90 100644 --- a/README.md +++ b/README.md @@ -230,9 +230,15 @@ const data = { }, } -await fetch('https://example.com', { body: data, method: 'POST' }) +await fetch('https://example.com', { body: data, method: 'POST', duplex: 'half' }) ``` +#### `request.duplex` + +- half + +In this implementation of fetch, `request.duplex` must be set if `request.body` is `ReadableStream` or `Async Iterables`. And fetch requests are currently always be full duplex. More detail refer to [Fetch Standard.](https://fetch.spec.whatwg.org/#dom-requestinit-duplex) + #### `response.body` 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()`.