Hello,
I want to insert in the Tweets collection every tweets from the stream made with Twit (npm module), inside a method.
Here is my code:
stream: function(hashtag) {
//Création du stream
stream = T.stream('statuses/filter', { track: hashtag });
var currentHashtag = hashtag;
// Lance le stream
stream.on('tweet', function (tweet) {
var userName = tweet.user.screen_name;
var userTweet = tweet.text;
var tweetDate = tweet.created_at;
var profileImg = tweet.user.profile_image_url;
console.log(userName+" a tweeté: "+userTweet+" le: "+tweetDate);
console.log("=======================");
Tweets.insert({user: userName, tweet: userTweet, picture: profileImg, date: tweetDate, hashtag: currentHashtag}, function(error) {
if(error)
console.log(error);
});
});
}
And here is my error message:
[Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor Libraries with Meteor.bindEnvironment. ]
I've tried different solutions in vain, like wrap the Collection insertion in a Fiber(), and I try to use a Meteor.bindEnvironment, but never understand how to properly use it.
Can you help me ?