I'm using Puppeteer to web scrap my website. I'm using await page.content() and console logging it and I'm getting the content in the logs but when I pass page as an argument to another javascript function. The await page.content() is null. Nothing is present in the content even though I can still see the content in the browser. I have no idea why this is happening, I did literally the same things for other url of the same website but they are working fine. Only in this case, the await page.content() is returning null. I know that I can pass await page.content() as an argument directly but that won't suffice because I have conditions when to call this, otherwise server load would be high.
func1(){
let a = await page.content()
console.log(a) // works fine and prints the html
}
func2(){
func3(page);
}
func3(page){
let c = await page.content()
console.log(c);
//Prints nothing
}
Before func3 add the keyword async. Later, write:
await func3(page)