Phantom.js と Meteor.js のphantom
NPM パッケージを使用すると、次のエラーが表示されます。Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
findOne
関数Meteor.wrapAsync
と Phantom のコールバック関数を でラップしようとしましMeteor.bindEnvironment
たが、エラーは解決しません。
私たちは何ができる?
var phantom = Meteor.npmRequire('phantom')
phantom.create(Meteor.bindEnvironment( function (ph) {
ph.createPage(function (page) {
page.open('http://www.google.com', function (status) {
console.log('Page Loaded');
page.evaluate( function () {
return document.documentElement.outerHTML;
}, function (html) {
// ERROR OCCURS HERE
Animals.findOneAsync = Meteor.wrapAsync(Animals.findOne)
var animals = Animals.findOneAsync({city:'boston'})
});
ph.exit();
});
});
}) );
エラー:
Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.