-
Notifications
You must be signed in to change notification settings - Fork 6
Express.js 中间件向下一个函数传递值 #193
Copy link
Copy link
Closed
Labels
Back-endWhere data really come and goWhere data really come and go
Description
解决过程
用关键词 express.js middleware pass data to next Google,找到答案:Passing variables to the next middleware using next() in Express.js。
简单来说,就是在中间件里把需要传递的值放到 res.locals 中,比如 res.locals.varr = varr,然后在下一个函数里就可以通过 res.locals.varr 来调用了。
官方文档:res.locals。
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Back-endWhere data really come and goWhere data really come and go