Hi folks,
I’m writing a module at the moment and have most of it covered, except loading in my config, some functions seem able to access this.config and others don’t
So first, I’m loading in config like this in node_helper.js:
socketNotificationReceived: function(notification, payload) {
switch(notification) {
case "INIT":
this.initConfigs(payload);
break
initConfigs: function(config) {
this.config = config;
this.sendSocketNotification('INIT-DONE');
this.init = true;
},
And I send that from the main.js by doing:
this.sendSocketNotification("INIT", this.config);
Which works, so in most functions I can then call
this.config.MyVariable and output it.
However in some functions if I try and call the same variable, I get an exception error:
[11:17:32.435] [ERROR] TypeError: Cannot read property 'verbose' of undefined
So it seems inconsistent.
How would I define this.config in node_helper.js to be a global variable, should I change reference, move it to a var at the top of node_helpher.js and set it there rather than using the internal this. functions for variable definitions?
Thanks in advance.