[英]How can I access request object in the loopback operational hooks?
I'm using loopback 3.x and I've written an Access Hook .我正在使用环回 3.x 并编写了一个Access Hook 。 I want to add some condition on the basis of User Agent .
我想在User Agent的基础上添加一些条件。
So I'm willing to access Request > Headers > User-Agent.所以我愿意访问请求> 标题> 用户代理。
Is it even possible to access it?甚至可以访问它吗? if no then is there any other way I can achieve it?
如果没有,那么我还有其他方法可以实现吗?
So I have managed to this using Remote hooks .所以我设法使用Remote hooks做到了这一点。
ModelName.beforeRemote('findById', (ctx, data, next) => {
// ctx has req object that further contains the headers and my work is done
})
But still I'm opening the question for the further question if it is possible to do in the access hooks但是,如果可以在访问挂钩中进行操作,我仍然会提出进一步的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.