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
Post a Comment