Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Use await response.json() to parse the body of a Puppeteer HTTPResponse. Check the HTTP status separately: a response can arrive with a 404 or 500 status and still contain a body, while json() rejects if that body is not valid JSON.
Parse the response body
For a navigation response, page.goto() returns the response for the page’s main resource when one exists. Guard against a missing response, check its status, then parse its JSON body:
As an Amazon Associate I earn from qualifying purchases.
const response = await page.goto('https://example.com/data');
if (!response) {
throw new Error('Navigation did not provide an HTTP response');
}
console.log('status:', response.status());
if (!response.ok()) {
throw new Error(`HTTP ${response.status()}: ${response.statusText()}`);
}
const data = await response.json();
console.log(data);
json() returns a promise that resolves to the value represented by the body. That value may be an object, array, string, number, boolean, or null; it is not necessarily an object. Puppeteer documents that parsing throws if the response body cannot be parsed by JSON.parse (HTTPResponse.json()).
Free tools Windows power users keep installed
One-click scans. No signup required.
Capture JSON from a browser interaction
When a click or other browser action triggers an API request, set up waitForResponse() before triggering the action. Filter by a stable endpoint detail and, where useful, the request method so another request is not mistaken for the one you need:
#1 Best Overall
const responsePromise = page.waitForResponse(response =>
response.url().includes('/api/items') &&
response.request().method() === 'GET'
);
await page.click('button.load-items');
const response = await responsePromise;
if (!response.ok()) {
throw new Error(`HTTP ${response.status()}: ${response.statusText()}`);
}
const items = await response.json();
console.log(items);
waitForResponse() accepts a URL or predicate, with timeout and cancellation options. Match the request that matters rather than assuming the next response belongs to the action; pages commonly make unrelated requests at the same time. See the Page.waitForResponse() reference.
Choose the right response source
| Situation | Use | Important check |
|---|---|---|
| You want the page’s main navigation resource | page.goto(url) |
It may return null, including navigation to about:blank or the same URL with only a different hash. Guard before calling response methods. |
| You want an API request caused by an interaction | page.waitForResponse(urlOrPredicate) |
Register the wait before the click or action, and narrow the match to the intended request. |
The relevant navigation and response behavior is documented in Puppeteer’s Page API.
Check status independently from JSON parsing
response.ok() is true only for HTTP status codes from 200 through 299. It tells you about status, not whether the body is valid JSON. A 404 or 503 can still be a completed HTTP response, and its body may be JSON, HTML, or another format. Decide how your code should handle non-2xx statuses before relying on the payload. Puppeteer documents status(), statusText(), ok(), and response headers in its HTTPResponse API.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Troubleshoot parsing and capture failures
response.json() throws
The body is not parseable JSON. Inspect the raw body and metadata to see what the server actually returned:
Rank #3
console.log('url:', response.url());
console.log('status:', response.status(), response.statusText());
console.log('headers:', response.headers());
console.log('body:', await response.text());
This often reveals an HTML error page or a different payload than expected. text() returns UTF-8 text and can itself throw if the content is not UTF-8. The response methods are described in the HTTPResponse reference.
The captured response is unrelated
Refine the waitForResponse() predicate using the endpoint, method, or another known property, and create the wait before the action. The page may issue multiple requests in response to a click.
Rank #4
The server returns 404 or 500
Check status() or ok() before treating the payload as success data. The body might be a JSON error object or an HTML error page; status alone does not identify its format.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchThe request fails instead of completing
A network failure is different from receiving an HTTP error response. Puppeteer distinguishes requestfailed from requestfinished; inspect the lifecycle of the specific request rather than assuming JSON parsing caused the failure. See the HTTPRequest API.
Best Value
page.goto() returns null
Some navigations do not produce a response object, including about:blank and a same-URL navigation that changes only the hash. Guard the return value before calling status() or json().
Or skip the browser setup
If your goal is a screenshot or PDF rather than parsing an API response, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request captures a URL; its API also supports PDF output. For example, save a screenshot as WebP:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Cookie banners, newsletter popups, and chat widgets are removed before capture by default, and each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status. An MCP server exposes screenshot tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 shots.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteSign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Is response.json() the same as JSON.stringify()?
No. response.json() parses a response body into a JavaScript value; JSON.stringify() serializes a JavaScript value into JSON text.
Can I use this method on a browser-side fetch() response?
The Fetch API has its own Response.json() method, but it belongs to the browser Fetch API and execution context, not Puppeteer’s HTTPResponse object.
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.




