I have a function that does a backend call and fetches an array of names. The function is like this.
module.exports.getTxnList = function(index, callback) {
....some operations
.....
....
callback(null, response);
};
I have one more function where i want to call this function and get this list. Both the functions are located in the same file.
The other function is something like this.
module.exports.getTxnAvailability = function(index, lid, callback) {
...
...
...
};
I tried lot of things but i am not getting the data from the former function.
This is what i tried to do.
var that = this;
that.getTxnList(index, function(response){
// Here you have access to your variable
console.log("List: " + response);
})
And this
var txnList=this.getTxnList(index);
Any help will be appreciated.