Response object

The Response object returned by fetch describes the HTTP response: status and ok (true for a 200 to 299 status), headers and the body. The body is read once through a method that returns a promise: json(), text() or blob(). You must check response.ok before reading the data.

Example

if (!r.ok) throw new Error(`HTTP ${r.status}`)
const data = await r.json()

Related concepts

The whole glossary