Skip to content

Commit 9d12321

Browse files
committed
fix: Add documentation for Request.prototype.clone()
1 parent 0e330b5 commit 9d12321

File tree

1 file changed

+34
-0
lines changed
  • documentation/docs/globals/Request/prototype

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
# Request.clone()
8+
9+
The **`clone()`** method of the `Request` interface creates a copy of the current `Request` object.
10+
11+
Like the underlying `ReadableStream.tee`` api, the `body` of a cloned `Response`
12+
will signal backpressure at the rate of the _faster_ consumer of the two bodies,
13+
and unread data is enqueued internally on the slower consumed `body`
14+
without any limit or backpressure.
15+
Beware when you construct a `Request` from a stream and then `clone` it.
16+
17+
`clone()` throws a `TypeError` if the request body has already been used. In fact, the main reason `clone()` exists is to allow multiple uses of body objects (when they are one-use only.)
18+
19+
If you intend to modify the request, you may prefer the `Request` constructor.
20+
21+
## Syntax
22+
23+
```js
24+
clone()
25+
```
26+
27+
### Parameters
28+
29+
None.
30+
31+
### Return value
32+
33+
A `Request` object, which is an exact copy of the `Request` that `clone()` was called on.
34+

0 commit comments

Comments
 (0)