Passing variables to the next middleware using next() in Express.js

后端 未结 6 1431
长情又很酷
长情又很酷 2020-11-27 10:11

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

6条回答
  •  粉色の甜心
    2020-11-27 10:37

    As mentioned above, res.locals is a good (recommended) way to do this. See here for a quick tutorial on how to do this in Express.

提交回复
热议问题