Closed sookinoby closed 5 years ago
Use: console.log(request._postData);
@sookinoby You should use request.postData()
.
console.log(request._postData.split("&"));
console.log(request.postData().split("&"));
Both of these work for me, can you explain the difference?
@smhall05 the _postData
is a private field - it is not supposed to be used and might change eventually. The postData()
is Puppeteer's public API - it will never change from now on.
When using google's puppeteer with request interception
//sample code const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.setRequestInterception(true);
//'some website with uses a tracker and post to backend using application/x-www-form-urlencoded the statistics of the website' await page.goto('https://www.maple-af.com/');
page.on('request', (request) => { console.log('REQUEST RECEIVED'); console.log(request.url); // none of these work (it prints either undefined or empty value) console.log(request.postData) console.log(request.formData) console.log(request.formData()) console.log(request.formData()) }) I inspected the whole request object in console and it shows empty.
However when I use chrome in headful (headless set to false) and manually inspect the request in dev tools, it form data is available.