Nest JS将动态对象从控制器传递到服务,而无需使用参数
我正在使用Nest JS.I有以下方案,当我处理HTTP请求时,我需要从控制器传递contured。 我需要访问服务中的定制,而无需将其传递在道具中。他们是注入自定义变量的方法吗?
I'm using nest js.I have the following scenario where i need to pass customId from controller where i got it using interceptor when i handled the http request.
I need to access customId in service without passing it in the props. Is their a way to inject custom variables ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加“定制”是请求对象
req.customid
应该有效。Adding "customId" is request object
req.customId
should work.我
在控制器i中创建了一个自定义,然后使用setID,然后我从UserRepository
Controller中读取ID:
USERREREPOSIOTRY:
I created an customRepository
In the controller i inject it and use setId then i read id from userRepository
controller:
userReposiotry: