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?
via Mike
No comments:
Post a Comment