I have this code
async function dataget(APIURL){
    let x = false;
    let xhr = new XMLHttpRequest();
    xhr.open("GET", APIURL);
    xhr.send();
    xhr.onload = await function(){
        if(1 == 1){
            x = true
        }else{
            x = "gg"
        }
    }
    console.log(x)
}
console.log(dataget("data.json"));
I want console to wait until onload function ends (when x = true), but this doesn't happen, console returns false and doesn't wait
this is the output:
I want an explanation not just the solve

 
     
    