Twitter 异步API调用错误

Twitter 异步API调用错误,twitter,meteor,Twitter,Meteor,我目前正在尝试使用meteor调用twitter API,到目前为止,我得到了以下结果: updateTotalFoll:function(){ var Twit = Meteor.npmRequire('twit'); var T = new Twit({ consumer_key: 'AWzYAlWFRh9zsownZMg3', consumer_secret: 'aYpL3zMPfqRgtX1usPQpEREEXVNPfNYna9FiIwTeDYR', access_tok

我目前正在尝试使用meteor调用twitter API,到目前为止,我得到了以下结果:

updateTotalFoll:function(){
var Twit = Meteor.npmRequire('twit');

var T = new Twit({
  consumer_key:  'AWzYAlWFRh9zsownZMg3',
  consumer_secret: 'aYpL3zMPfqRgtX1usPQpEREEXVNPfNYna9FiIwTeDYR',
  access_token:  '4175010201-TEp9qNKO4mvjkj0GMjJFZIbGPYaVv4',
  access_token_secret:  'EPpcJyN27E4PvhJpYaTHflNFOv3DuR05kTP2j'
});

var Id2=RandomCenas.findOne({api:"twitter"})._id;

T.get('statuses/user_timeline', { screen_name: 'jeknowledge' },  function (err, data, response){
  //console.log(data[0].user.followers_count);
  RandomCenas.update(Id2,{$set:{totalFoll:data[0].user.followers_count}});
});

}
“RandomCenas”是MongoDB。 我试图用电话中的信息更新这个集合,但是我得到了这个错误

 Error: Meteor code must always run within a Fiber. 
 Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
我在网上搜索了一种方法来解决这个问题,但我似乎无法应用我遇到的解决方案。 有什么能帮我解决这个问题的吗?

就这样试试吧

T.get('statuses/user_timeline', { screen_name: 'jeknowledge' },  Meteor.bindEnvironment(function (err, data, response) {
  //console.log(data[0].user.followers_count);
  RandomCenas.update(Id2,{$set:{totalFoll:data[0].user.followers_count}});
}));
发生这种情况的原因是因为您传递的回调函数它发生在当前Meteor的光纤之外检查答案

T.get('statuses/user_timeline', { screen_name: 'jeknowledge' },  Meteor.bindEnvironment(function (err, data, response) {
  //console.log(data[0].user.followers_count);
  RandomCenas.update(Id2,{$set:{totalFoll:data[0].user.followers_count}});
}));

发生这种情况的原因是因为您传递的回调函数它发生在当前Meteor的光纤外部检查答案

哦,我使用的是twit软件包,我使用的是twit软件包。它工作正常,非常感谢您的帮助!我被这件事困扰了几天,现在我可以继续了!谢谢你的帮助!我被这件事困扰了几天,现在我可以继续了!干杯