I'm working with puppeteer and trying to send an xhr requesr after login. Using devtools network tab, I copied the request of interest using the fetch api option. I wrapped it in the page.evaluate function as below:
let x = await page.evaluate((SecureAuthToken) => {
return fetch("/api/Search/PropertySearch", {
headers: {
"accept": "application/json, text/plain, */*",
"accept-language": "en-US,en;q=0.9",
"content-type": "application/json;charset=UTF-8",
"sec-ch-ua":
'" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Chrome OS"',
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"secureauthtoken": SecureAuthToken,
},
referrerPolicy: "no-referrer",
body: '{"Filters":[{"FieldId":9,"BundleChildren":.....}',
method: "POST",
mode: "cors",
credentials: "include",
});
},SecureAuthToken);
I'm passing in the SecureAuthToken. when I do
console.log(x)
The result is
[]
What am I doing wrong? Also is there a good way to debug this?