I am trying to pass variable to the next middlewares through the req object.
getting some data from database and passing that data to request for next middlewares to use.
User.findone({ _id: someId })
.then(user => { req.user = user })
.catch(err => { })
After that then and catch block i am using next().
Therefore for the next middlewares i am getting req.user undefined.
but if i pass the next() function in the then block after
req.user = user like .then(user=> {req.user = user; next()}) than i am getting req.user a valid user object to use for the next middlewares.
what is the reason for this behaviour??