Reputation: 1056
I have the following class
class Foo {
baz = 42
url = 'www.foo.bar'
foo(){
console.log('Hello from foo')
return 'baz'
}
run() {
let nightmare = Nightmare()
var _this = this
nightmare
.on('console', (log, msg) => {
console.log(msg)
})
.goto(this.url)
.evaluate((ctx)=>{
console.log('hello from evaluate')
ctx.foo()
return 'title'
}, _this)
.end()
.then(function(title){
console.log(title);
})
}
}
I try to divide up the scraping into methods, but I can't find out how to call a member from the evaluate function. I can only see
hello from evaluate
It looks like foo is never called.
Upvotes: 0
Views: 55