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 Read POST Data from a Request in Puppeteer

Use Puppeteer’s request event and await request.fetchPostData() to read POST bodies without enabling request interception.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Listen for Puppeteer’s request event, filter for POST requests, and call await request.fetchPostData(). You do not need request interception just to inspect a request body. Because the method returns string | undefined, handle the case where the body is unavailable.

Read a POST body from the request event

Register a listener on the page before the action that triggers the request. The listener receives an HTTPRequest; use request.method() to select POST requests and fetchPostData() to retrieve the body.

As an Amazon Associate I earn from qualifying purchases.

page.on('request', async request => {
  if (request.method() !== 'POST' || !request.hasPostData()) {
    return;
  }

  const postData = await request.fetchPostData();
  console.log(postData);
});

hasPostData() is an optional guard: it reports whether the request has POST data. The result of fetchPostData() can still be undefined, so code that needs to distinguish a readable body from an unavailable one should check it explicitly:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
page.on('request', async request => {
  if (request.method() !== 'POST') return;

  const body = await request.fetchPostData();
  if (body === undefined) {
    console.log('POST body unavailable');
    return;
  }

  console.log(body);
});

Attach this listener before submitting a form, clicking a button, or otherwise causing the request. Page request events can include traffic other than the action you care about, so narrow the filter further when needed:

page.on('request', async request => {
  if (request.method() !== 'POST' || !request.url().includes('/your-endpoint')) {
    return;
  }

  const body = await request.fetchPostData();
  console.log(body);
});

Replace /your-endpoint with a distinguishing part of the target URL. Puppeteer’s request events are for page-initiated network requests, not exclusively form submissions.

Why use fetchPostData() instead of postData()?

request.postData() is deprecated. Puppeteer notes that it may be undefined when the data is too long or not readily available in decoded form. Use and await request.fetchPostData() in current code; it fetches the POST data from the browser and resolves to string | undefined. See the Puppeteer HTTPRequest API and the documentation for fetchPostData().

The API documentation does not promise a particular serialization format for every content type. Treat the result as a string and interpret it using the request’s headers and the conventions of the application sending it; do not assume every body is JSON or form-encoded.

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.

Do not enable interception just to read data

The ordinary request event is enough for observation. Request interception is a separate feature for modifying, aborting, or fulfilling requests. Once interception is enabled, each request stalls until it is resolved, unless the browser cache completes it. See Puppeteer’s network and request interception guide.

If interception is already needed for another task, resolve every request on every code path. Other listeners may resolve a request while your handler is awaiting asynchronous work, so check isInterceptResolutionHandled() immediately before calling continue(), abort(), or respond(). Keep the check and resolution call together without an intervening await:

await page.setRequestInterception(true);

page.on('request', async request => {
  const body = await request.fetchPostData();
  console.log(body);

  // Another handler may have resolved it while this handler awaited.
  if (request.isInterceptResolutionHandled()) return;
  request.continue();
});

For interception-specific behavior and coordination details, use the Puppeteer request interception guide. If you do not need to change network traffic, omit interception entirely.

Troubleshoot missing bodies and stalled requests

  • postData() is undefined: It is deprecated and can be unavailable for long or not-readily-decoded data. Switch to await request.fetchPostData() and handle an undefined result.
  • fetchPostData() returns undefined: The API allows this result. Check hasPostData(), inspect the request headers and content type, and confirm that you are handling the request you intended.
  • The listener catches unrelated requests: Filter by method and, where appropriate, URL or other request properties. A page can initiate multiple requests around one user action.
  • Navigation hangs after enabling interception: A request path may not be resolving. Ensure every intercepted request is continued, fulfilled, or aborted, and avoid slow asynchronous work before resolution when possible.
  • “Request is already handled!” appears: Another listener or package may have resolved the request. Check isInterceptResolutionHandled() immediately before resolving, with no asynchronous gap between the check and the call.

The current Puppeteer API and guide pages reviewed identify version 25.12.0; the dedicated fetchPostData() page identifies 25.8.0. Check the documentation matching your installed Puppeteer version if behavior or availability differs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API, not a way to retrieve a page’s POST body. If what you need is a clean screenshot of a URL rather than request data, one GET request returns an image or PDF:

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 documentation for API details. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Sign up for 1,000 free screenshots a month, with no card.

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.

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

Leave a Reply

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

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

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.