Closed BrunyC closed 2 years ago
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?
This is a Javascript misunderstanding, not related to this lib or moleculer https://medium.com/tech-tajawal/javascript-this-4-rules-7354abdb274c
I created methods but when I call inside action I receive an error:
TypeError: this.myMethod is not a function
code:
What is missing?