Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
Puppeteer page's content when I pass it to another function vanishes

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
}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Before func3 add the keyword async. Later, write:

await func3(page)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!