1
我試圖使用騎馬者內的承諾evalute函數。一個簡單的例子:有諾言的節點騎士
var Horseman = require('node-horseman');
var horseman = new Horseman();
horseman
.open('http://google.com')
.evaluate(function() {
var promise = new Promise(function(resolve,reject){
setTimeout(function(){resolve("Hello")},2000);
});
return promise;
})
.then(function(mesg){
console.log(mesg);
})
.close();
我期待解析值「你好」將被傳遞到下一個然後函數作爲MESG參數時,許滿了,而是我發現了以下錯誤:
Unhandled rejection fn
evaluate
global code
[email protected][native code]
[email protected]://platform/webpage.js:390:39
我錯過了什麼嗎?