I am trying to use res.locals
to pass data between middlewares in a Restify app, but TypeScript is blocking me.
Do I need a plugin or is there an alternative solution for passing data between middlewares?
I am trying to use res.locals
to pass data between middlewares in a Restify app, but TypeScript is blocking me.
Do I need a plugin or is there an alternative solution for passing data between middlewares?
Yes, you need a plugin to use res.locals
in a Restify app with TypeScript. One alternative solution for passing data between middlewares is to use req.data
instead of res.locals
. You can define a custom interface for req
to include the data
property and use it in your middlewares.