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

292
Views
How to pass an object into phantom js page using async/await approach?

Here is the script I run using 'node --harmony-async-await run'

I want to collect logs into 'logs' array. But the array is undefined inside await function.

const phantomjs = async ({ development, script }) => {
  const instance = await phantom.create()
  const page = await instance.createPage()
  const logs = []

  await page.property('onConsoleMessage', function(msg, lineNum, sourceId) {
    console.log('Console:', msg)
    logs.push(msg) // => will be not executed. logs is undefined here
  })
  ....some other actions
}

How to pass msg into array?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I think it is because page.property does not return a promise, it means that there is no meaning use await page.propperty(xxx, function () {}). so maybe you can try to wrap your page.propperty first

over 4 years ago · Santiago Trujillo 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!