LOGBOOK

HELP

Quiz Entry - updated: 2026.07.05

What methods are available on the Response object to read the body?

The Response object hands you the body through a family of reader methods, and you pick the one that matches the data's format.

When fetch() resolves, you don't yet have the actual payload - you have a Response object with the headers and status, while the body is still streaming in over the network. That is why every reader method returns a Promise: you await it to let the rest of the body arrive and get decoded. Choose the reader by what the server sent:

  • text() - reads the body as a UTF-8 string (HTML, plain text, CSV)
  • json() - reads the body and runs JSON.parse() on it, giving you a ready-to-use object; the most common choice for APIs
  • blob() - returns a Blob of binary data, ideal for images or files you want to display or download
  • arrayBuffer() - returns the raw bytes for low-level processing (e.g. decoding audio, parsing a binary protocol)

A concrete example: fetching a profile picture URL, you would await response.blob() and feed it to URL.createObjectURL() to show it in an <img>. Fetching /api/users, you would await response.json().

The big gotcha: the body is a one-time stream, so you can only call one of these methods once. Calling response.json() after response.text() (or twice) throws "body already used". If you genuinely need it twice, call response.clone() first to get a second readable copy.

Go deeper:

  • doc MDN: Response interface — full list of reader methods (text, json, blob, arrayBuffer, formData) plus clone() and bodyUsed.

From Quiz: WEBT / Backend Integration | Updated: Jul 05, 2026