Why is "req.headers" nowhere to be found on express's documentation?

Since req, in this case, is an express object, I’m wondering why req.headers is not documented. Yet, you can find the req.header() (without s)counterpart on the documentation. Is it that the property headers does not belong to express? Or is it that I’m confused about the “req” object and it does not belong to express?

1 Like

I’m wondering why too, my guess is req doesn’t belong to express, but belongs to Node.js. Hope some experts can confirm this.

1 Like

Right. First of all, it is mentioned - you can google "req.headers" site:expressjs.com and see that. But yeah, it is part of standard http so express feels no need to explain it, for the same reason that it feels no need to explain how JS works.

You can find discussions elsewhere, like here.

2 Likes

Thanks @kevinSmith for the accurate reply!

Just one more thing, is the req object from express exaxtly the same as the one from the web api (like the link you’ve sent on MDN)?

On express, the best I found is :

The req object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on. In this documentation and by convention, the object is always referred to as req (and the HTTP response is res ) but its actual name is determined by the parameters to the callback function in which you’re working.

And it is not completly clear to me.

Just to be clear, you’d want to search for that whole string if you want google to show you where that is on the express site.

Yes, they are the same objects. They should be exactly the same, express is just passing them through to you.

Thanks Kevin, I did that search and found how it is mentioned on express’s web