Quantcast
Channel: Where is the body in a nodejs http.get response? - Stack Overflow
Browsing latest articles
Browse All 24 View Live

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

The body is not fully stored as part of the response, the reason for this is because the body can contain a very large amount of data, if it was to be stored on the response object, the program's...

View Article



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

Just an improved version to nkron responce.const httpGet = url => { return new Promise((resolve, reject) => { http.get(url, res => { res.setEncoding('utf8'); const body = []; res.on('data',...

View Article

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

The data event is fired multiple times with 'chunks' of the body as they are downloaded and an end event when all chunks have been downloaded.With Node supporting Promises now, I created a simple...

View Article

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

You can't get the body of the response from the return value of http.get().http.get() doesn't return a response object. It returns the request object (http.clientRequest). So, there isn't any way to...

View Article

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

Needle module is also good, here is an example which uses needle module var needle = require('needle');needle.get('http://www.google.com', function(error, response) { if (!error &&...

View Article


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

A portion of Coffee here:# My little helperread_buffer = (buffer, callback) -> data = '' buffer.on 'readable', -> data += buffer.read().toString() buffer.on 'end', -> callback data# So request...

View Article

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

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:...

View Article

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

If you want to use .get you can do it like this http.get(url, function(res){ res.setEncoding('utf8'); res.on('data', function(chunk){ console.log(chunk); });});

View Article


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

http.request docs contains example how to receive body of the response through handling data event:var options = { host: 'www.google.com', port: 80, path: '/upload', method: 'POST'};var req =...

View Article


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

Edit: replying to self 6 years laterThe await keyword is the best way to get a response from an HTTP request, avoiding callbacks and .then()You'll also need to use an HTTP client that returns...

View Article

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

You need to add a listener to the request because node.js works asynchronous like that:request.on('response', function (response) { response.on('data', function (chunk) { console.log('BODY: '+ chunk);...

View Article

Where is the body in a nodejs http.get response?

I'm reading the docs at http://nodejs.org/docs/v0.4.0/api/http.html#http.request, but for some reason, I can't seem to to actually find the body/data attribute on the returned, finished response...

View Article
Browsing latest articles
Browse All 24 View Live




Latest Images