Web APIs

Request.clone()

Try the free JavaScript compiler

Create another Request with the same request data and a separately consumable body. Cloning an already disturbed or locked body fails; avoid unbounded buffering. Example console output: hello hello.

Formal Syntax & Structure

javascript syntaxjavascript
request.clone()

Return Value

Request

Cloned request.

Working Example

Example Snippetjavascript
(async () => {const r=new Request("https://example.invalid/items",{method:"POST",body:"hello"}); const copy=r.clone(); console.log(await r.text(),await copy.text());})()
JavaScript Reference