req.method

The HTTP method of the request.

Since Express 4 Spec ↗

Syntax

req.method

Returns

string — Uppercase verb such as 'GET', 'POST', 'DELETE'.

Examples

app.use((req, res, next) => {
  console.log(`${req.method} ${req.path}`);
  next();
});
Output
POST /users
app.all('/resource', (req, res) => {
  if (req.method === 'DELETE') return res.sendStatus(204);
  res.send(req.method);
});
Output
$ curl localhost:3000/resource
GET

Notes

Always uppercase. Browsers preflight cross-origin non-simple requests with an `OPTIONS` request - handle it (or use the `cors` middleware) so real requests succeed.

See also