Node.js 我可以通过Express中的下一个函数传递数据吗?

Node.js 我可以通过Express中的下一个函数传递数据吗?,node.js,express,Node.js,Express,在使用Express时,我的路线如下: app.get('*', function (req, res, next) { // no route is matched // so call next() to pass to the static middleware next(); }); 还有另一个路由类似于app.get'/myroute',functionreq,res,next 我能把信息从第一条路线传递到下一条路线吗?谢谢@amakhrov。我可以使用res.local

在使用Express时,我的路线如下:

app.get('*', function (req, res, next) {
  // no route is matched
  // so call next() to pass to the static middleware
  next();
});
还有另一个路由类似于app.get'/myroute',functionreq,res,next


我能把信息从第一条路线传递到下一条路线吗?

谢谢@amakhrov。我可以使用res.locals和存储信息。

谢谢@amakhrov。我可以使用res.locals和存储信息。

我相信您可以使用res.locals在单路由处理chainapp.locals或req.localsreq.locals.requestTimestamp=microtime中传递数据。现在给我:500 TypeError:无法设置未定义的属性'requestTimestamp',我相信您可以使用res.locals在单路由中传递数据路由处理chainapp.locals或req.localsreq.locals.requestTimestamp=microtime.now提供:500 TypeError:无法设置未定义的属性'requestTimestamp'