Read a Puppeteer response body with an asynchronous method on its HTTPResponse object: use await response.text() for UTF-8 text, await response.json() for parsed JSON, or await response.content() / await response.buffer() for bytes. First make sure you captured the response you want, then check its status separately from reading its body.
Read the body using the method that matches its format
Puppeteer does not expose the body as a synchronous response.body property. Its body-reading methods return promises, so await the method before using the result.
As an Amazon Associate I earn from qualifying purchases.
| What you need | Method | Result | Important caveat |
|---|---|---|---|
| Readable text | await response.text() |
UTF-8 string | Throws if the body is not valid UTF-8. |
| JSON data | await response.json() |
Parsed JavaScript value | Throws if the body cannot be parsed as JSON. |
| Body bytes | await response.content() |
Uint8Array |
The browser may re-encode bytes based on headers or heuristics. |
| Node.js Buffer operations | await response.buffer() |
Buffer |
Returned bytes may reflect browser re-encoding. |
The official Puppeteer HTTPResponse reference is for version 25.12.0 and documents content() as resolving to Uint8Array; use HTTPResponse API for the current API details.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Read a navigation response
page.goto() resolves to the main resource’s response, or null in cases such as navigating to about:blank or changing only the URL hash. Redirects lead to the final response. In headless shell, an HTTP status such as 404 or 500 does not by itself make navigation throw, so inspect the returned response.
#1 Best Overall
const response = await page.goto('https://example.com/api/data');
if (!response) {
throw new Error('No main resource response');
}
console.log('status:', response.status());
console.log('URL:', response.url());
console.log(await response.text());
For JSON, replace the final line with console.log(await response.json()). page.goto() is for the navigation’s main resource; it is not a general way to retrieve every request the page makes. See the Page.goto() API for its documented return behavior.
Capture a later request triggered by the page
If a click or page script triggers the API request, start waiting for the response before performing the action. Filter on a distinctive URL or other response property so you do not accidentally read a script, image, or unrelated request.
Rank #2
const responsePromise = page.waitForResponse(response =>
response.url().includes('/api/data')
);
await page.click('button.load-data');
const response = await responsePromise;
console.log(await response.json());
For more control, include the request method or other relevant details in the predicate. The waitForResponse() API documents this response-waiting approach.
Free tools Windows power users keep installed
One-click scans. No signup required.
You can also listen for responses and filter them. Because the event listener below is asynchronous, errors from reading or parsing a body should be handled if they must not become unhandled rejections.
page.on('response', async response => {
if (response.url().includes('/api/data')) {
try {
console.log(await response.text());
} catch (error) {
console.error('Could not read response body:', error);
}
}
});
The response event and its relationship to request completion are described in the PageEvent API.
Check status separately from the response body
A response object means Puppeteer received an HTTP response; it does not mean the server returned a successful status. Use response.ok() for a boolean indicating a 2xx status, or inspect response.status() for the exact code. You can still read an error page or error payload from a 404 or 503 response.
Rank #4
const response = await page.goto('https://example.com/api/data');
if (!response) throw new Error('No main resource response');
if (!response.ok()) {
console.error('HTTP status:', response.status());
console.error('Body:', await response.text());
} else {
console.log(await response.json());
}
Puppeteer’s PageEvent documentation explains that HTTP error responses such as 404 or 503 complete with requestfinished, not requestfailed. A request failure instead represents a failure such as a timeout. Check the status and body for HTTP errors; use request-failure handling for network-level problems.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Troubleshoot body-reading problems
- The response is missing:
page.goto()can returnnullfor documented special navigations. Check fornullbefore calling a body method. - You captured the wrong response: Make the
waitForResponse()predicate more specific, for example by matching the endpoint and, if useful, the request method. json()throws: The body may be malformed JSON or not JSON at all. Read it withtext()while diagnosing, then parse or handle the payload appropriately.text()throws: The body may not be valid UTF-8. Usecontent()orbuffer()when you need byte-oriented handling.- You expected a network failure but received a response: An HTTP 4xx or 5xx status is still an HTTP response. Inspect
status()and the body rather than relying onrequestfailed. - Bytes differ from what you expected on the wire: Puppeteer documents that the browser may re-encode content based on headers or heuristics. Do not assume the returned body bytes are always an exact copy of the original wire representation.
Or skip the browser setup
If your goal is a website screenshot rather than inspecting an API payload, ScreenshotNeo returns a screenshot or PDF from one GET request. Its screenshot capture accepts cookie and consent banners like a visitor, then removes 60+ known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. It also provides an MCP server with screenshot, page-info, and PDF tools for AI agents.
Example request using cURL (see the ScreenshotNeo documentation):
Best Value
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for 1,000 free screenshots a month, with no card required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

