Response Body Methods
You'll learn how to extract different data formats from a fetch response using five specialized body methods.
The Core Idea
When you receive a Response object from fetch(), the actual data payload is locked inside the body. You can't just read response.body directly as usable data. Instead, JavaScript provides five different methods to extract and parse that body based on what format you're expecting:
.json()– Parses the body as JSON and returns a JavaScript object.text()– Reads the body as plain text (a string).blob()– Returns the body as a Blob (useful for images, files).arrayBuffer()– Returns raw binary data as an ArrayBuffer.formData()– Parses the body as form data (key-value pairs)
Each method returns a Promise that resolves to the appropriate data type.
Think of It Like Unlocking a Package
The response is like a sealed package. These methods are different tools to open it based on what's inside: .json() is for structured data boxes, .text() is for reading letters, .blob() is for handling physical items, .arrayBuffer() is for raw materials, and .formData() is for catalog forms.
Choosing the Right Method
Use .json() for API responses, .text() for HTML or plain content, .blob() for downloading images or PDFs, .arrayBuffer() when you need byte-level control (like audio processing), and .formData() when working with form submissions.
Key Takeaway: The Response object provides five body methods—.json(), .text(), .blob(), .arrayBuffer(), and .formData()—each returning a Promise that parses the response body into the format you need.