I am having trouble figuring out a way to pass an object method, rather than sorting the "generic prototype" method on a callback.
function Client() { this.name = "hello"; } Client.prototype.apiCall = function(method, params, callback) { callback(); } Client.prototype.onLogin = function(error, data) { console.log(this.name);
I pass the onLogin method, but it does not work. This is the code I rewrote. I previously nested all the methods inside the Client function, but I realized that this is not a way to do this, so now I am trying to use a prototype.
I know that there is some solution linking the onLogin function inside the Client () function, but I want to understand the problem.
javascript
Todilo
source share