Created
April 11, 2015 00:21
-
-
Save IPRIT/049319797060663acd0a to your computer and use it in GitHub Desktop.
This file contains hidden or 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'); | |
| 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