Skip to content

Instantly share code, notes, and snippets.

@IPRIT
Created April 11, 2015 00:21
Show Gist options
  • Select an option

  • Save IPRIT/049319797060663acd0a to your computer and use it in GitHub Desktop.

Select an option

Save IPRIT/049319797060663acd0a to your computer and use it in GitHub Desktop.
var http = require('http');
var bl = require('bl');
module.exports = function(url, callback) {
var result = '';
http.get(url, function(res) {
res.setEncoding('utf8');
res.pipe(bl(function(err, data) {
result += data.toString();
}));
res.on('error', function(e) {
callback(e);
});
res.on('end', function() {
callback(null, result);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment