CKTIS / JavaScript
Response — a Fetch API response
Response represents a Fetch API response: its status, headers, and body. The body is read asynchronously.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
new Response()
new Response(body)
new Response(body, init)
response.status
response.ok
response.headers
await response.json()
response.clone()Response is a Web API defined by the Fetch Standard, not part of ECMAScript. fetch() returns a Promise that fulfills with a Response object. You can also construct one with new Response(body, init).
status contains the response code, ok means status 200–299, and headers exposes headers. response.json() asynchronously reads the body and parses JSON; it does not create a response, unlike the static Response.json() method.
A non-null body is generally single-use. bodyUsed is true when the body stream is disturbed. Canceling the stream without reading it also sets bodyUsed to true, so the flag does not tell you whether reading has started. If the response has a body stream, call clone() while the stream is neither disturbed nor locked. Check Web API availability in the target browser; the repository's Node version does not establish it.
Examples
async function main() {
const response = new Response('{"name":"Ada"}', {
status: 201,
headers: { "Content-Type": "application/json" }
});
console.log(response.status, response.ok, response.bodyUsed);
const data = await response.json();
console.log(data.name, response.bodyUsed);
}
main().catch(console.error);Result
201 true false Ada true
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.