const data=[];
async function getData(){
response= await fetch(url);
jData= await response.json();
for(var i in jData[1].state_data)
data.push(jData[1].state_data[i]);
console.log(data);//FIRST CONSOLE LOG
}
getData();
console.log(data);//SECOND CONSOLE LOG
I want to insert the objects into an array that can be used elsewhere. But the second console.log is giving me an empty array. I do understand that it has something to do with global and local allocation but I can't seem to solve this issue.