title: Get latest tweets with nodejs and the twitter api
body: <p>I am trying to get the latest 5 tweets with the twitter api and node / express, but I am not getting any result, when I call the url with .get</p>
  
  <p>I would expect it to return a json object, when I am calling the url</p>
  
  <p>Here is my code for the call, inspired from what I have found elsewhere and the answer here <a href="https://stackoverflow.com/questions/19254499/get-the-list-of-latest-tweets-using-node-js-and-twitterapi">Get the list of latest tweets using node.js and twitterAPI</a></p>
  
  <pre><code>var ntwitter = require('ntwitter'),
  credentials = require('./credentials.json'),
  twitter,
  tweets = {};
  
  // set up our twitter objects
  twitter = ntwitter(credentials);
  
  
  tweets = twitter.get('/statuses/user_timeline.json', { screen_name: 'twitter', count: 5});
  
  module.exports = tweets;
  </code></pre>
  
  <p>At the moment I am getting this error, when I start the server</p>
  
  <pre><code>    throw new Error('FAIL: INVALID CALLBACK.');
        ^
      Error: FAIL: INVALID CALLBACK.
      at Twitter.get (/home/vagrant/app/node_modules/ntwitter/lib/twitter.js:56:11)
      at Object.&lt;anonymous&gt; (/home/vagrant/app/twitter_stream.js:10:18)
      at Module._compile (module.js:456:26)
      at Object.Module._extensions..js (module.js:474:10)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:312:12)
      at Module.require (module.js:364:17)
      at require (module.js:380:17)
      at Object.&lt;anonymous&gt; (/home/vagrant/app/server.js:7:19)
      at Module._compile (module.js:456:26)
  </code></pre>
  
  <p>And my server.js file where I require the twitter_stream.js file</p>
  
  <pre><code>var express     = require("express"),
  path        = require("path"),
  http        = require("http"),
  bodyParser  = require("body-parser"),
  tweets      = require("./twitter_stream.js"),
  app         = express();
  
  
  // Set the client folder as the default folder
  app.use(express.static(__dirname + "/client"));
  
  // Parse incomming json objects with bodyparser
  app.use(bodyParser());
  
  // Create the server
  http.createServer(app).listen(3000);
  
  // set up routes
  app.get("/tweets.json", function (req, res) {
      // res.json returns the entire object as a JSON file
      res.json(tweets);
  });
  </code></pre>
  
  <p>Just as an extra info: I am running node from a vagrant 64 bit box</p>
  
  <p>Haven't been able to find much info on this, so I might be handling this completely wrong. </p>