loopbackjs - Pass context in 'persist' to 'after save' -


i need pass context operation hook (persist) (after save), know existence of ctx.hookstate not working.

zz.observe('persist', (ctx, next) => {       ctx.hookstate = "pass this";       next();     }).catch(err => next(err));   });  zz.observe('after save', (ctx, next) => {   console.log(ctx.hookstate);   next() }); 

i don't in console.log(ctx.hookstate). i'm doing wrong?

thanks.

you shouldn't overwrite hookstate

you can :

zz.observe('persist', (ctx, next) => {       ctx.hookstate.foo = "pass this";       next();       });  zz.observe('after save', (ctx, next) => {   console.log(ctx.hookstate.foo);   next() }); 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -