Well, my question is I want to pass some variable from the first middleware to another middleware, and I tried doing this, but there was \"req.somevariable is a
req.somevariable
Attach your variable to the req object, not res.
req
res
Instead of
res.somevariable = variable1;
Have:
req.somevariable = variable1;
As others have pointed out, res.locals is the recommended way of passing data through middleware.
res.locals