From ce1f8ff4ea921703e1d2081d869e2c79cf22f4de Mon Sep 17 00:00:00 2001 From: zizifn <515868058@qq.com> Date: Wed, 9 Nov 2022 00:20:20 +0800 Subject: [PATCH 1/2] 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..0d931076c07 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()`. From 07e44d4544c1b4c18f8546405f06eb328e20099c Mon Sep 17 00:00:00 2001 From: zizifn <515868058@qq.com> Date: Wed, 9 Nov 2022 00:23:31 +0800 Subject: [PATCH 2/2] chore(doc/fetch) update doc for fetch duplex (#1760) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d931076c07..bd991008a90 100644 --- a/README.md +++ b/README.md @@ -230,7 +230,7 @@ const data = { }, } -await fetch('https://example.com', { body: data, method: 'POST', duplex: "half" }) +await fetch('https://example.com', { body: data, method: 'POST', duplex: 'half' }) ``` #### `request.duplex`