Having a strange issue where im trying to parse some JSON for use with Chart.JS .. I can console log within the function and use the array so to say as expected but outside of that function even though i have made it a Global variable the array is empty after the function runs and i print it out to the console.
var data = {}
const api_url = "http://localhost:5000/"
var currentPage = window.location.href
currentPage = currentPage.split("/")
currentPage = api_url + currentPage[4]
console.log(currentPage)
async function getJson() {
const response = await fetch(currentPage);
data = await response.json();
console.log(data)
}
getJson()
console.log(data)