Reputation: 109
I am getting the following error.
Uncaught TypeError: Cannot read property 'on' of undefined
it happens when I add in the line of code
let ServicePlugin = new ServicePlugin();
Any Idea what I am doing wrong? Below is the full code.
'use strict';
class ServicePlugin {
constructor(api) {
this._api = api;
this._api.on('ready', () => this._apiReady());
this._api.on('saveSuccess', () => this._apiSuccess());
}
_apiReady() {
console.log('Plugin Ready')
}
_apiSuccess() {
console.log('Plugin Success');
}
}
let ServicePlugin = new ServicePlugin();
ServicePlugin._apiReady();
module.exports = ServicePlugin;
Upvotes: 1
Views: 129
Reputation: 7887
You must provide the learnosity
parameter (whatever that is) when you instantiate your class. AnnServicePlugin
expects it:
let annServicePlugin = new AnnServicePlugin(learnosity);
Of course, the learnosity
object must have the expected on
method.
Upvotes: 3