moleculer-cron
moleculer-cron copied to clipboard
How can I call methods?
I created methods but when I call inside action I receive an error:
TypeError: this.myMethod is not a function
code:
crons: [
{
name: "Cron-Job",
cronTime: process.env.CRON_TIMER,
onTick: function() {
this.getLocalService("RefreshToken").actions.mainAction();
},
manualStart: false
},
],
actions: {
mainAction: {
async handler() {
const result = this.myMethod();
// do something with result;
},
},
},
methods: {
myMethod() {
return "something";
}
}
What is missing?