I've seen a lot of posts on here that show how to make an asynchronous function call using callbacks. I've made it work, however, I can't seem to find how to utilize the variable retrieved from the function outside of the function.
var json = JSON.parse(body);
var accountID = json.accountId;
var getMatchData;
getRecentMatchData(accountID, function(err, res) {
getMatchData = res;
//console.log(res);
});
console.log(getMatchData);
I'm trying to use getMatchData to pass into other functions in my app.post but it prints out as undefined. How can I access this variable to use outside of the asynchronous method? Do I use another callback?