Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

How to Get a Request’s Response in Puppeteer

Get an HTTPResponse from an existing Puppeteer request with request.response(), or wait for a future response with page.waitForResponse() before triggering the action.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If you already have a Puppeteer HTTPRequest, call request.response(). It returns the matching HTTPResponse after one arrives, or null while the response is still pending. If a click or other action will cause the response, register page.waitForResponse() before performing that action, then await the response.

Get the response from an existing request

Use HTTPRequest.response() when you already hold the request object:

As an Amazon Associate I earn from qualifying purchases.

page.on('request', request => {
  const response = request.response();

  if (response) {
    console.log(response.status(), response.url());
  } else {
    console.log('The response has not arrived yet');
  }
});

The method is an accessor, not a waiter: its result can be null if called before the response arrives. The Puppeteer HTTPRequest API describes the result as a matching HTTPResponse object or null if the response has not been received.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Wait for a response caused by an action

For a response expected after a click, navigation, or other page action, use page.waitForResponse(). Start the wait first so Puppeteer is listening before the action can produce the response.

const responsePromise = page.waitForResponse(response =>
  response.url().includes('/api/data') &&
  response.request().method() === 'GET'
);

await page.click('button#load-data');
const response = await responsePromise;

console.log('Status:', response.status());
console.log('Body:', await response.json());

The URL fragment and selector above are examples; replace them with the endpoint and control used by your page. A predicate can match on URL, status, method, or other response/request properties. The Puppeteer Page.waitForResponse reference documents URL and asynchronous-predicate matching.

Match the response you mean

Pages can make several requests at once. Match enough details to avoid resolving on an unrelated response, for example a distinctive URL and the outgoing method. If you know the expected status, include it too:

const responsePromise = page.waitForResponse(response =>
  response.url() === 'https://example.com/api' &&
  response.status() === 200
);

await page.click('#submit');
const response = await responsePromise;

Read status and body

After the promise resolves, HTTPResponse provides methods such as status(), ok(), url(), text(), and json(). Choose the body reader that matches the response content; json() requires a JSON response body.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the API for the job

  • Already have an HTTPRequest: call request.response(); it may be null until the response arrives.
  • Need the outgoing request: use page.waitForRequest(urlOrPredicate). It resolves to an HTTPRequest, whose response may still be pending.
  • Need the incoming response: use page.waitForResponse(urlOrPredicate).
  • Need to observe all page traffic: listen for the page’s request and response events.

See the official HTTPRequest reference and Page.waitForRequest reference for their respective lifecycle and return values.

Understand request and response lifecycle events

Puppeteer distinguishes when a request is issued, when a response arrives, and when the response body has finished downloading. The page’s request event supplies an HTTPRequest; response supplies an HTTPResponse; requestfinished marks completion of the request and body download. A request-level failure emits requestfailed instead of requestfinished and may occur without a response event. The Puppeteer Page events reference documents these events.

Do not confuse an HTTP error status with a transport-level failure. A 404 or 503 is still an HTTP response and, according to Puppeteer’s event documentation, completes through requestfinished, not requestfailed. Inspect response.status() or response.ok() to evaluate the HTTP result separately from whether the request failed at the request level. See the HTTPResponse reference.

Redirects create a new request

A redirect response completes the original request and causes a new request to the destination URL. If the final URL differs from the one you expected, inspect the request URLs and redirect chain rather than assuming the original request’s URL will identify the final response.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Timeouts and troubleshooting

The current Puppeteer Page.waitForResponse() reference is labeled version 25.12.0 and documents a default timeout of 30 seconds. The timeout can be changed with Page.setDefaultTimeout(), overridden with the wait’s timeout option, or disabled for a particular wait with timeout: 0. The API also accepts an abort signal. Check the installed Puppeteer version’s reference if your project uses a different release.

Symptom Likely explanation What to check
request.response() returns null The response has not arrived when the accessor is called. Wait with page.waitForResponse() when you need a future response, or handle the page’s response event.
waitForResponse() times out No response matched the URL or predicate during the wait period, or the action did not initiate the expected request. Register the wait before the trigger; confirm the action fires; check the actual URL, method, and predicate conditions.
The wait resolves on the wrong response The predicate matches a different request made by the page. Narrow it using a more specific URL, method, or expected status.
A request appears to fail despite an HTTP status An HTTP error response and a request-level failure are different outcomes. Inspect the response status separately; 404 and 503 responses are not themselves requestfailed events.
The final URL does not match the initial one The server redirected the request and the browser issued a new request. Inspect the redirect chain and the URLs of subsequent requests.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a screenshot or PDF rather than inspecting network traffic in your own Puppeteer session, ScreenshotNeo can return one from a GET request. Its API accepts the URL and can return PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. It also offers an MCP server with screenshot, page-info, and PDF tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Does `page.waitForRequest()` give me the response?

No. It resolves to an `HTTPRequest`; use `page.waitForResponse()` to await an `HTTPResponse`.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does a 404 trigger `requestfailed`?

No. Puppeteer treats 404 and 503 as HTTP responses that complete through `requestfinished`; check the response status to determine whether the HTTP result is successful.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.