Created
August 6, 2012 16:14
-
-
Save heapwolf/3276019 to your computer and use it in GitHub Desktop.
emitters/http
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 req = http.request(options); | |
req.on('response', function(response) { | |
response.on("data", function(data) { | |
console.log("some data from the response", data); | |
}); | |
response.on("end", function() { | |
console.log("response ended"); | |
}); | |
}); | |
req.on('error', function(err) { | |
console.error('request error:', err); | |
}); | |
req.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Suppose you have a long data stream that comes back from a REST service response. Is the best thing to do is collect the chunked data on the data emitter and then do something with that chunk on the end emmitter, say as follows: