Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Response Headers with node request module

I'm trying to retrieve the server response header for a request from a server.

import 'request' from 'request'

var url = "SOME_URL"

var options = { url: url };

var callback = function(error, response, body) {
    if(!error){
        console.log(response); // <==
    }
}

request(options, callback)

Going through the "response" object it doesn't look like it contains the Server response-header http://www.tutorialspoint.com/http/http_header_fields.htm

The only header being returned after doing this

console.log(response.headers)

is from the client request header.

Can anyone point in towards the right direction in order to access this object.

like image 824
philip_nunoo Avatar asked Mar 12 '23 07:03

philip_nunoo


1 Answers

use

response.headers

instead of

response.header

like image 156
Amin Cheloh Avatar answered Mar 21 '23 01:03

Amin Cheloh