📜  res.locals in express - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:37.885000             🧑  作者: Mango

代码示例1
req.locals, res.locals or even your own defined key res.userData can be used. However, when using a view engine with Express, you can set intermediate data on res.locals in your middleware, and that data will be available in your view (see this post). It is common practice to set intermediate data inside of middleware on req.locals to avoid overwriting view data in res.locals, though this is not officially documented.