I cannot figure out how to keep the constructor scope or whatever ever you want to call it, it simply gets replaced with the global variables.
I will be calling multiple functions and each will generate different data and will set different variables;
How can I solve this?
function Foo(user, data) {
this.user = user;
this.data = data;
}
Foo.prototype.init = function(callback) {
async.series([
this.functionOne,
], function(err, result) {
callback(err, []);
});
};
Foo.prototype.functionOne = function(callback) {
console.log(this);
this.username = "abc";
callback(null);
}
module.exports = Foo;