Closed mabc224 closed 3 years ago
Correct example: https://codesandbox.io/s/moleculer-sample-forked-3lget
Can you write the example here, codesandbox code is not available anymore
I am seeing this issue as well. How do I inject meta into an event?
Ok, I figured it out. If you specify a meta key in the options object, the ctx.meta is then populated:
await serviceBroker.emit(
'eventName',
{ foo: 'bar' },
{
meta: {
auth: {}
}
}
);
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Current Behavior
I am calling an action, and the action has
ctx.meta
available. as I set it during authorize phase. In hooks -> after, I change some response based on condition and emit an event. Emitting event has all data but missing meta. When I accessctx.meta
, it is empty.Expected Behavior
It should have
ctx.meta
available.Failure Information
Steps to Reproduce
Call action
in hooks, after phase, emit an event,
this.broker.emit('user..created', data, ['test']);
try to access,
ctx.meta
, It is emptyReproduce code snippet
https://codesandbox.io/s/moleculer-sample-forked-wji7t?file=/index.js
Context