在Meteor.js中使用NPM包时必须在光纤错误内运行
我正在使用NPM OAuth库,因为我无法让Meteor的工作。我得到这个错误 错误:Meteor代码必须始终在光纤中运行。尝试使用Meteor.bindEnvironment包装传递给非Meteor库的回调 如果我删除Collection.upsert行,它就会工作在Meteor.js中使用NPM包时必须在光纤错误内运行,meteor,Meteor,我正在使用NPM OAuth库,因为我无法让Meteor的工作。我得到这个错误 错误:Meteor代码必须始终在光纤中运行。尝试使用Meteor.bindEnvironment包装传递给非Meteor库的回调 如果我删除Collection.upsert行,它就会工作 var OAuth = Meteor.require('oauth').OAuth; var oa = new OAuth(null, null, consumer_key, consumer_secret, "1.0", nu
var OAuth = Meteor.require('oauth').OAuth;
var oa = new OAuth(null, null, consumer_key, consumer_secret, "1.0", null, "HMAC-SHA1");
var request = oa.post("https://stream.api.com/blah.json", access_token, access_secret);
request.on('response', function (response) {
response.setEncoding('utf8');
response.on('data', function(data) {
var j = JSON.parse(data)
Collection.upsert({symbol: j.symbol}, {last: j.last})
})
});
request.end();
我读过Meteor.Bind环境和Meteor.\u wrapAsync,但无法让它工作 Collection.upsert方法在嵌入光纤中时有效,而request.on的回调是任意调用的,而不是用一个方法包装。试试这个:
request.on('response', function (response) {
new Fiber(function(){
response.setEncoding('utf8');
response.on('data', function(data) {
var j = JSON.parse(data)
Collection.upsert({symbol: j.symbol}, {last: j.last})
});
}).run();
});
Collection.upsert方法在嵌入光纤中时有效,而request.on的回调被任意调用,而不是用一个方法包装。试试这个:
request.on('response', function (response) {
new Fiber(function(){
response.setEncoding('utf8');
response.on('data', function(data) {
var j = JSON.parse(data)
Collection.upsert({symbol: j.symbol}, {last: j.last})
});
}).run();
});
当您尝试使用Meteor的身份验证时发生了什么?在url中传递变量时,我得到了无效的签名。使用NPM Oauth可以很好地工作。当您尝试使用Meteor的身份验证时会发生什么情况?在url中传递变量时,我得到了无效的签名。与NPM Oauth配合使用效果良好。