Meteor Newb here. I’m digging through the packages and I’m interested in streaming tweets. I found the mrt:user-stream package and see that there is a code example for streaming tweets to the console. Which file would I put this block of code in to get the tweets to stream via console. Do I need to create a server folder and put this code in there? any help is appreciated. Thanks
here is the code (I already have all my twitter keys):
var Stream = require(‘user-stream’);
var stream = new Stream({
consumer_key: ‘’,
consumer_secret: ‘’,
access_token_key: ‘’,
access_token_secret: ‘’
});
//create stream
stream.stream();
//listen stream data
stream.on(‘data’, function(json) {
console.log(json);
});
Just try it But yes, this would need to go into a file in /server. And you don’t have to require user-stream. That’s already been done. So just leave out the first line, and save your file.
: )
I just created a new Meteor project to test it and it worked great. Should be quite clear what to do and the only thing I can imagine is that you forgot to add the package. If not that’s what I did:
meteor create twitter-test
Remove all files from twitter-test/
Create a folder server with a file twitter.js inside
Run meteor add mrt:user-stream
Paste this code into the twitter.js file, without the first line (var Stream = require('user-stream');)