Is there any way to pass data from a onPre* hook to a onPost* hook for the same request? I do a database lookup in the pre-hook and would like to avoid doing the same thing in the post-hook. I tried assigning to a new property on the 'response' and 'request' object, but that did not seem to work. I know I could potentially stuff the data in 'request.body' and access it in 'response.body', but then it goes into the database which is undesirable. Any tips?
If's not possible today, perhaps move this to 'Feature Request'?
Good timing, this is actually something we are looking to implement in the next couple of weeks. We'll add something like request.temporaryStorage, which you can add stuff to during onPre and will be propagated to onPost.
about 5 years ago
Ah perfect :) Thanks Ivan!
almost 5 years ago
We've released a new tempObjectStore module in BL, that allows you to store data between pre-hooks and post hooks. Usage is as follows: