Express req.method Property

Beginner
⏱️ 8 min read
📚 Updated: May 2026
🎯 4 Code Examples

What you’ll learn

  • What value req.method provides for each request.
  • How to build method-aware middleware and logs.
  • How method overrides can affect request flow.
  • How to validate allowed HTTP methods safely.

Usage syntax

javascript
req.method
1

Method-based response in shared route

javascript
app.all('/resource', function (req, res) {
  if (req.method === 'GET') return res.send('Read resource');
  if (req.method === 'POST') return res.send('Create resource');
  res.status(405).send('Method Not Allowed');
});
2

Log request method in middleware

javascript
app.use(function (req, res, next) {
  console.log('Method:', req.method, 'Path:', req.originalUrl);
  next();
});

❓ FAQ

It gives the HTTP request method, such as GET, POST, PUT, PATCH, or DELETE.
Typically yes for standard Node/Express request handling, e.g., GET or POST.
It is useful in shared middleware for logging, auditing, conditional checks, and method-based behavior.
Yes. Method override patterns may rewrite the effective method before route handling.
Route methods define allowed verbs, while req.method tells which verb the current request used.
Did you know?

req.method contains the incoming HTTP verb (like GET, POST, PUT, DELETE) and is useful in generic middleware logic.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

4 people found this page helpful