'View Express JS response headers?
If I need to see the incoming request headers I use: req.headers.
I need to see the list of all headers that will be in the response.
res.headers is undefined.
I know I can set response headers: res.header('', '').
How do I view the response headers..?
Solution 1:[1]
Solution 2:[2]
Also:
res.get('Content-Type'); // => "text/plain"
and, confusingly, lowercase is fine:
res.get('content-type');
// => "text/plain"
res.getHeaders()['content-type']
// => "text/plain"
Solution 3:[3]
You Can This Method ...
/* ----------------------- Get Response Header By Name ---------------------- */
/* res.getHeader('Put Header Name Here'); */
/* For Example */
res.getHeader('x-powered-by');
This Method Help You To Get Response Header Name
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
| Solution 2 | ptim |
| Solution 3 | Milad Fathy |
