aryaksengupta
3/3/2015 10:34:00 AM
Hi everyone,
I am new to Nodejs and Socket.io. I have worked through a tutorial which describes how both the technologies work together. The link to the tutorial is this :--- > Build a real-time Twitter stream
and the code for the tutorial is posted at github :---> Code of react-tweets.
Everything works fine in the tutorial and I also have no issues in understanding the code since the code is well commented.
In the server.js file, the tracking keyword which is "javascript" is manually fed into the "twit" object. i.e. here is the code for it.
twit.stream('statuses/filter',{ track: 'javascript'}, function(stream){
streamHandler(stream,io);
});
But I want to make a minor alteration in the code to make the application a bit more versatile. I want to change the tracking keyword dynamically using the URL entered by the user.
For example, if the URL entered is http://localhost/football, then automatically I want the track keyword to be changed to "football". The code should look like
twit.stream('statuses/filter',{ track: 'football'}, function(stream){
streamHandler(stream,io);
});
Now, I tried to set this object inside the app.get("/cricket", twit.stream.......); function but I get an error "Expected callback got object" .
How do I change the above mentioned code to achieve this?. Please let me know.
Thanks a lot.