Express Request Methods

About This Index
This page is the Express Request index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.
In every route handler, Express passes (req, res). Use this page when you need request data such as req.params, req.query, or req.body.
Start with req.params, req.query, and req.body—then req.get() for headers and req.ip for the client address.
How to Read the Request Object
Access properties and helpers on req inside middleware and routes:
app.get("/users/:id", (req, res) => {
const id = req.params.id;
const page = req.query.page;
const agent = req.get("User-Agent");
res.json({
id,
page,
method: req.method,
path: req.path,
ip: req.ip,
agent
});
});
app.post("/items", express.json(), (req, res) => {
if (!req.is("json")) {
return res.sendStatus(415);
}
res.status(201).json(req.body);
}); Express Request Methods Table
All Request property and method guides in this Express.js tutorial series (29 tutorials).
Request Data
5 methodsRead what the client sent — params, query, body, and cookies.
| Method | Description | Tutorial |
|---|---|---|
req.params | Named route parameters from the matched path (for example /users/:id). | Try it |
req.query | Parsed query-string values from the URL after ?. | Try it |
req.body | Parsed request body — filled by express.json() / express.urlencoded(). | Try it |
req.cookies | Parsed cookies object when cookie-parser middleware is used. | Try it |
req.signedCookies | Signed cookies verified by cookie-parser — tamper-resistant values. | Try it |
URL & Routing
5 methodsInspect method, path, mount base, original URL, and matched route.
| Method | Description | Tutorial |
|---|---|---|
req.method | HTTP method string for the request — GET, POST, PUT, DELETE, and more. | Try it |
req.path | Path portion of the URL — useful inside mounted routers. | Try it |
req.baseUrl | URL path on which a router instance was mounted. | Try it |
req.originalUrl | Original request URL including query string — unchanged by mounts. | Try it |
req.route | The currently matched Route object — path, stack, and methods. | Try it |
Headers & Negotiation
7 methodsRead headers and negotiate Accept / Content-Type / Range.
| Method | Description | Tutorial |
|---|---|---|
req.get() | Read a request header by name (case-insensitive). | Try it |
req.is() | Check if the Content-Type matches a type string such as json or html. | Try it |
req.accepts() | Content negotiation — pick the best Accept type the client allows. | Try it |
req.acceptsCharsets() | Negotiate preferred character sets from Accept-Charset. | Try it |
req.acceptsEncodings() | Negotiate preferred encodings from Accept-Encoding. | Try it |
req.acceptsLanguages() | Negotiate preferred languages from Accept-Language. | Try it |
req.range() | Parse Range headers for partial content / file downloads. | Try it |
Host & Connection
8 methodsProtocol, host, client IP, subdomains, and XHR detection.
| Method | Description | Tutorial |
|---|---|---|
req.protocol | Request protocol — http or https (respects trust proxy). | Try it |
req.secure | True when the connection is HTTPS (shortcut for protocol === 'https'). | Try it |
req.hostname | Hostname from the Host / X-Forwarded-Host header. | Try it |
req.host | Host header value including optional port. | Try it |
req.ip | Remote IP address of the client (respects trust proxy). | Try it |
req.ips | Array of IP addresses from X-Forwarded-For when trust proxy is set. | Try it |
req.subdomains | Subdomain labels parsed from the hostname. | Try it |
req.xhr | True when X-Requested-With is XMLHttpRequest (classic AJAX). | Try it |
Cache Freshness
2 methodsCheck whether conditional GET responses are still fresh.
App & Response Links
2 methodsReach the owning app and the paired res object from req.
Frequently Asked Questions
Start with req.params
Open the route-params guide—syntax, examples, and FAQs.
CODETOFUN NEWS
Stay Ahead in Tech
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
16 people found this page helpful
