So as the title says, I was wondering if this is possible.
const sleep =()=> new Promise((resolve, reject)=> setTimeout(resolve, 800));
const asyncMethod = async ()=> {
await sleep();
console.log("asyncMethod");
return 1;
}
const getData =()=> {
let data = null;
asyncMethod().then(x=> data =x);
/// while(data ==null) This dose not work
console.log("data", data)
}
getData() // the log should log asyncMethod and then data 1
Is this even possible?