Response.prototype.clone
Creates a clone of the Response object, identical in every way but stored in a different variable
Syntax
response.clone()Return Value
A new Response that is a copy of this Response
Examples
const response = await fetch('/api/data')
const clone = response.clone()
const json = await response.json()
const text = await clone.text()
console.log(json, text)async function fetchAndCache(url: string) {
const response = await fetch(url)
const clone = response.clone()
const cache = await caches.open('v1')
cache.put(url, clone)
return response.json()
}async function logAndReturn(url: string) {
const res = await fetch(url)
const copy = res.clone()
console.log('Status:', res.status)
console.log('Body:', await copy.text())
return res
}Understanding Response.prototype.clone
The Response.prototype.clone method in JavaScript creates a clone of the Response object, identical in every way but stored in a different variable. It belongs to the Response object and is one of the most widely used methods for working with response values in modern JavaScript and TypeScript applications.
The method signature is response.clone(). When called, it returns a new response that is a copy of this response. Understanding when and how to use clone() helps you write more expressive, readable code.
Common use cases for Response.prototype.clone include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like fetch-response-json, fetch-response-text, request-constructor, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Response.prototype.clone is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
Response.prototype.jsonTakes a Response stream and reads it to completion, parsing the result as JSON
Response.prototype.textTakes a Response stream and reads it to completion, returning the result as a string
RequestCreates a new Request object representing a resource request that can be passed to fetch()
More Response Methods
Other methods in the Response object
Related Tools
More Response Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.