moleculer-cron icon indicating copy to clipboard operation
moleculer-cron copied to clipboard

How can I call methods?

Open BrunyC opened this issue 2 years ago • 0 comments

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?

BrunyC avatar Apr 12 '22 20:04 BrunyC