Skip to content

Commit

Permalink
chore(doc/fetch) update doc for fetch duplex (#1760) (#1765)
Browse files Browse the repository at this point in the history
* chore(doc/fetch) update doc for fetch duplex (#1760)

* chore(doc/fetch) update doc for fetch duplex (#1760)
  • Loading branch information
zizifn committed Nov 25, 2022
1 parent d16327c commit 0ab830b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Expand Up @@ -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()`.
Expand Down

0 comments on commit 0ab830b

Please sign in to comment.