Reputation: 1409
Is there any way to access the request object that is sent to any route without accessing it in a .get or something like that but instead access any request sent to express globally?
Upvotes: 0
Views: 642
Reputation: 943556
Yes. That's the most of the point of middleware.
Quoting from the documentation:
var requestTime = function (req, res, next) { req.requestTime = Date.now() next() } app.use(requestTime)
Upvotes: 2