Quantcast
Channel: Where is the body in a nodejs http.get response? - Stack Overflow
Viewing all articles
Browse latest Browse all 24

Answer by bizi for Where is the body in a nodejs http.get response?

$
0
0

I also want to add that the http.ClientResponse returned by http.get() has an end event, so here is another way that I receive the body response:

var options = {  host: 'www.google.com',  port: 80,  path: '/index.html'};http.get(options, function(res) {  var body = '';  res.on('data', function(chunk) {    body += chunk;  });  res.on('end', function() {    console.log(body);  });}).on('error', function(e) {  console.log("Got error: "+ e.message);}); 

Viewing all articles
Browse latest Browse all 24

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>