Created
November 15, 2013 00:31
-
-
Save hatched/7477033 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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