Reputation: 1460
Hi I've got this request i'm trying to intercept and override its postData.
Here's my method of doing it:
await page.setRequestInterception(true);
var staticWebPayloadData = {"sensor_data": "temperatureReading&70deg"};
page.on('request', req => {
if (req.url().includes('staticweb')){
req.continue({
'postData': JSON.stringify(staticWebPayloadData)
});
}
else{
req.continue();
}
});
But it doesn't work. Am i doing something wrong?
Upvotes: 1
Views: 1107
Reputation: 51
try this
await page.route('staticweb/**', route => {
if (route.request().postData().includes('my-string'))
route.fulfill({ body: 'mocked-data' });
else
route.continue();
});
Upvotes: 0