Start a new topic

Passing data from pre hook to post hook

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.

Ah perfect :) Thanks Ivan!
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:


modules.utils.tempObjectStore.set('myKey', 'myValue);



For more information, see
Perfect thanks! I have a few follow up questions (which I can probably test myself, but it's Monday and I'm lazy):

1) Does it only accept string values like HTML5 LocalStorage? Or can it take a Javascript object?

2) What is the limit on the amount of data to be passed? Just a ballpark figure..

3) Is the data limit enforced per key? Or for the total object store?

Great work!
1) It can contain JavaScript objects

2) Ballpark, I wouldn't submit anything > 500 kb

3) The data limit is for the total object store
Login or Signup to post a comment