'Add a custom query parameter in Feathers request
I'm hoping to add a custom query parameter that can be used in a hook to process some results.
I'd like to add $foo=bar to the request. I can whitelist $foo and it appears in the request, but the service is using an ORM so it tries to query the database for $foo=bar.
In a before hook, I can strip $foo from the params.query, but is there somewhere else in the context of the hook that I could stash the value of $foo so that I can act on it in an after hook?
Solution 1:[1]
I used to delete the params once the functionality is over here we added customer variable $paginate in before find hook.
find: [
(hook) => {
if (hook.params.query && hook.params.query.$paginate) {
hook.params.paginate =
hook.params.query.$paginate === 'false' ||
hook.params.query.$paginate === false;
delete hook.params.query.$paginate;
}
return hook;
}
],
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pash |
