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?
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.
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.
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 asreq
(and the HTTP response isres
) 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
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.