Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Use Puppeteer’s page.waitForResponse() when you need to wait for a matching network response, such as the result of an API call triggered by a click. Start the wait before the action, then await the returned HTTPResponse.
Wait for a response triggered by an action
Create the response-wait promise before clicking, submitting, or performing the action that sends the request. Then perform the action and await the promise. This ordering avoids missing a fast response before the wait is set up.
As an Amazon Associate I earn from qualifying purchases.
const responsePromise = page.waitForResponse(response =>
response.url() === 'https://example.com/api/data' && response.status() === 200
);
await page.locator('button.load-data').click();
const response = await responsePromise;
const body = await response.json();
page.waitForResponse() accepts a URL string or an asynchronous predicate and resolves to the matching response. The example uses a predicate so it can check both the URL and status. See the Puppeteer Page.waitForResponse() reference.
Match the response you actually need
A URL string is adequate when only one response can match it. Use a predicate when an endpoint is called repeatedly, query parameters vary, or the request method and response status matter.
#1 Best Overall
const responsePromise = page.waitForResponse(async response => {
if (response.url() !== 'https://example.com/api/search') return false;
if (response.request().method() !== 'POST') return false;
return response.status() === 200;
});
await page.locator('button.search').click();
const response = await responsePromise;
Receiving a response does not necessarily mean the operation succeeded. HTTP error responses such as 404 or 503 are still responses. If your script requires success, test the expected status or another application-specific condition and handle error responses explicitly.
Read the response body
Once the wait resolves, the result is an HTTPResponse. Read its body using the method that matches the response format—for example, json() for JSON or text() for text. If the body is not the expected format, inspect the response URL and status before parsing it.
Rank #2
Set a timeout and cancel when needed
The response wait defaults to a 30-second timeout. You can set a shorter or longer finite timeout in the options object. A timeout of 0 disables the timeout; the page-level default timeout can also change the default. A signal option supports cancellation. For routine automation, keep a finite timeout so a missing request does not leave the script waiting indefinitely.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsconst responsePromise = page.waitForResponse(
response => response.url().includes('/api/data'),
{ timeout: 10_000 }
);
Choose a wait that matches the condition
| What you need to wait for | Puppeteer method | What it gives you |
|---|---|---|
| A matching network response | page.waitForResponse() |
The matching HTTPResponse |
| A matching outgoing request | page.waitForRequest() |
The matching request, not its response |
| A selector to appear, become visible, or become hidden | page.waitForSelector() |
An element handle, or a timeout if the requested condition is not met |
| A custom condition in the page context to become truthy | page.waitForFunction() |
The function result |
| An element to be ready for an interaction | Locators | Locator actions wait for the element to be present and suitable for the action |
Do not use a navigation wait as a substitute for an XHR or fetch response when the action does not navigate. Choose the API that represents the event or state your script needs to observe. See the Puppeteer page-interactions guide, waitForRequest() reference, waitForSelector() reference, and waitForFunction() reference.
Troubleshoot a wait that times out
- The triggering action did not run: Confirm the click or submit completed and that the control was actionable. Puppeteer locators wait for an element to be present and suitable for the action.
- The predicate does not match: Log observed response URLs, request methods, and statuses, then adjust the predicate to match the actual request. Check query parameters and redirects if relevant.
- The wait starts too late: Create the
waitForResponse()promise before the action that triggers the request. - The endpoint responds with an error status: The wait can still resolve. Inspect
response.status()and handle the application error rather than treating receipt as success. - The response takes longer than the timeout: Set a finite timeout appropriate to the task and investigate why the request is slow. Avoid disabling the timeout unless an indefinite wait is intentional.
Or skip the browser setup
If your goal is a website screenshot rather than Puppeteer response handling, ScreenshotNeo offers a one-request screenshot API:
Quick Recap
Best Value
Rank #4
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 the request options. Cookie banners are accepted and removed before capture, along with supported newsletter popups and chat widgets; those cleanup steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server provides screenshot tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.
Sign up for ScreenshotNeo’s free plan.
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.




