how to set payload in cheerio crawler preNavigationHooks

doing it like this:
preNavigationHooks:[async (crawlingContext, gotOptions) => {
const { request } = crawlingContext;
request.payload = `.......`;
}
preNavigationHooks:[async (crawlingContext, gotOptions) => {
const { request } = crawlingContext;
request.payload = `.......`;
}
does not work, error: ReferenceError: page is not defined also when I want to set headers, should I use gotOptions.headers= or request.headers= what is the difference?
3 Replies
optimistic-gold
optimistic-gold3y ago
Looks like a bug, will tell team to check
absent-sapphire
absent-sapphire3y ago
Need to see full error stack since under Cheerio page not supposed to be used. I guess you might be setting payload for GET request and crawler gone wild. As for headers - I using request.headers in one of the actors, works fine
genetic-orange
genetic-orangeOP3y ago
so it was bug in my code 🤦‍♂️ it has nothing to do with puppeteer page I had payload like this .....${page} but it was too long and way out of the screen to notice it

Did you find this page helpful?