I'm trying to create an array of data which I get from an API. As a searched here, due to the asynchronous nature of the get request I should use a callback function to make this work. I managed to create it and alert or console.log the result. The function is this (no need to show the complete implementation):
loadData(function(result){
console.log(result); // prints correct result
});
This result
seems to be just a reference. How can I assign the result to a global variable in order to use it in my code together with other variables? By the way the result
is an array. So I want to make an array from the result
that I can use in different ways. Is my logic totally wrong?