I made a class, which saves in a user login and password array:
function AccountManager() {
this.accounts = {};
}
AccountManager.prototype.createAccount = (login, password) => {
this.accounts[login] = password;
};
module.exports = AccountManager;
And in index.js, I created a test account:
var accountManager = new lib.AccountManager();
accountManager.createAccount("test", "test");
But it says that accounts
is undefined.
this.accounts[login] = password; ^ TypeError: Cannot set property 'test' of undefined at AccountManager.createAccount (c:\users\natha\documents\visual studio 2017\Projects\WarfaceXmpp\WarfaceXmpp\lib\Utils\AccountManager.js:6:23) at Object.<anonymous> (c:\users\natha\documents\visual studio 2017\Projects\WarfaceXmpp\WarfaceXmpp\app.js:6:16) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Timeout.Module.runMain [as _onTimeout] (module.js:605:10) at ontimeout (timers.js:386:14) at tryOnTimeout (timers.js:250:5)