2

I'm trying to figure out how to access the headers that were sent by a node-fetch request. When i do this, for example:

const response = await fetch('http://playground.localhost')

The response object seems to contain only information about the response(like response headers, body, url, etc), without any "Request" object, like Axios exposes. In the latter you would be able to access the headers via response.request.headers.

Is there any way to show information about the actual request, and not just the response?

i.brod
  • 3,993
  • 11
  • 38
  • 74

1 Answers1

-1

This might help: https://www.npmjs.com/package/node-fetch#accessing-headers-and-other-meta-data

    .then(res => {
        console.log(res.ok);
        console.log(res.status);
        console.log(res.statusText);
        console.log(res.headers.raw());
        console.log(res.headers.get('content-type'));
    });```
Andy
  • 59
  • 2
  • 11