A quick reference for the req object's most commonly used properties and methods.
Properties
| Property | Description |
|---|---|
req.app | Reference to the current Express app instance. |
req.baseUrl | The path on which a router is mounted. |
req.body | Parsed request body (needs a body-parsing middleware). |
req.cookies | Cookies sent by the client (needs cookie-parser). |
req.fresh | Whether the client's cache is still fresh. |
req.hostname | Hostname derived from the Host header. |
req.ip | The client's IP address. |
req.ips | IPs from X-Forwarded-For when trust proxy is enabled. |
req.method | The HTTP method used. |
req.originalUrl | The original request URL before internal rewrites. |
req.params | Named route parameters. |
req.path | The path portion of the URL. |
req.protocol | http or https. |
req.query | Query-string parameters. |
req.route | The matched route. |
req.secure | true if the connection uses TLS. |
req.signedCookies | Signed cookies (needs cookie-parser with a secret). |
req.stale | The inverse of req.fresh. |
req.subdomains | Subdomains present in the hostname. |
req.xhr | true for XMLHttpRequest-based requests. |
Methods
| Method | Description |
|---|---|
req.accepts() | Checks acceptable content types. |
req.acceptsCharsets() | Checks acceptable character sets. |
req.acceptsEncodings() | Checks acceptable content encodings. |
req.acceptsLanguages() | Checks acceptable languages. |
req.get() | Reads a request header. |
req.is() | Checks the request's content type against a MIME type. |
Keep this table handy when you need to quickly recall what a particular req property or
method does.