最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Getting Response Headers with node request module - Stack Overflow

programmeradmin3浏览0评论

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

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

Share Improve this question edited Aug 25, 2016 at 16:24 philip_nunoo asked Aug 25, 2016 at 12:20 philip_nunoophilip_nunoo 9384 gold badges10 silver badges22 bronze badges 1
  • I am facing the same problem. Were you able to find a solution to this ? – Pratik Singhal Commented Nov 10, 2017 at 14:19
Add a ment  | 

1 Answer 1

Reset to default 7

use

response.headers

instead of

response.header

发布评论

评论列表(0)

  1. 暂无评论