Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Response.ok — checking response status

Response.ok is a read-only Boolean property indicating whether the response status is in the inclusive range 200–299.

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

response.ok

Read Response.ok as response.ok, without parentheses. It returns true for statuses 200–299 inclusive and false otherwise. It belongs to the Fetch API, not ECMAScript itself.

HTTP statuses 404 and 500 do not themselves reject the fetch() promise: check response.ok after fulfillment. A network error can reject the promise before you receive a response. A value of true does not validate the body or confirm application-level success; reading ok does not consume the body.

Examples

for (const status of [200, 204, 299, 300, 404, 500]) {
  const response = new Response(null, { status });
  console.log(`${response.status}: ${response.ok}`);
}

Result

200: true
204: true
299: true
300: false
404: false
500: false

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources