Response.prototype.status
Returns the HTTP status code of the response
Syntax
response.statusReturn Value
An integer representing the HTTP status code
Examples
const res = await fetch('/api/data')
console.log('Status:', res.status) // 200const res = await fetch('/api/users/999')
if (res.status === 404) {
console.log('User not found')
} else if (res.status === 403) {
console.log('Access denied')
}async function fetchWithRetry(url: string, retries = 3) {
for (let i = 0; i < retries; i++) {
const res = await fetch(url)
if (res.status !== 503) return res
await new Promise(r => setTimeout(r, 1000 * (i + 1)))
}
throw new Error('Max retries exceeded')
}Understanding Response.prototype.status
The Response.prototype.status method in JavaScript returns the HTTP status code of the response. 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.status. When called, it returns an integer representing the http status code. Understanding when and how to use status() helps you write more expressive, readable code.
Common use cases for Response.prototype.status include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like fetch-response-ok, fetch-response-json, response-constructor, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Response.prototype.status 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
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.