Node.js fetching Twitter Streaming API - EADDRNOTAVAIL
- by Jordan Scales
I have the following code written in node.js to access to the Twitter Streaming API. If I curl the URL below, it works. However, I cannot get it to work with my code.
var https = require('https');
https.request('https://USERNAME:[email protected]/1.1/statuses/sample.json', function(res) {
res.on('data', function(chunk) {
var d = JSON.parse(chunk);
console.log(d);
});
});
But I receive the following
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: connect EADDRNOTAVAIL
at errnoException (net.js:642:11)
at connect (net.js:525:18)
at Socket.connect (net.js:589:5)
at Object.<anonymous> (net.js:77:12)
at new ClientRequest (http.js:1073:25)
at Object.request (https.js:80:10)
at Object.<anonymous> (/Users/jordan/Projects/twitter-stream/app.js:3:7)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
If anyone can offer an alternative solution, or explain to me why this doesn't work, I would be very grateful.