简体   繁体   中英

How can I access request object in the loopback operational hooks?

I'm using loopback 3.x and I've written an Access Hook . I want to add some condition on the basis of 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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM