Skip to content

Instantly share code, notes, and snippets.

@hatched
Created November 15, 2013 00:31
Show Gist options
  • Save hatched/7477033 to your computer and use it in GitHub Desktop.
Save hatched/7477033 to your computer and use it in GitHub Desktop.
var http = require('http'),
util= require('util');
var req = http.get('http://www.reddit.com/r/golang.json', function(res) {
var body = "";
if (!/^2[0-9]{2}$/.exec(res.statusCode)) {
console.log(res.statusCode);
}
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
console.log(util.inspect(
JSON.parse(body), {
showHidden:false, depth: null
}));
});
});
req.on('error', function(error) {
console.log(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment