I am trying to get data from a function in a node module, that returns a json object, and show the json object in a router in my server.js file.
I am trying to export it like this:
// Export the function
exports.getTweets = function() {
var tweetResult = {};
twitter.get(
'/statuses/user_timeline.json',
{ screen_name: 'twitter', count: 5},
function (error, tweets) {
tweetResult = tweets;
}
);
return tweetResult;
};
And here is my server.js file, with the route that should return the json object
tweets = require("./twitter_stream.js"),
// set up the route for the json object
app.get("/tweets.json", function (req, res) {
console.log(tweets.getTweets());
});
I haven't been able to get anything but an empty object.