let a = null;
const sleep = async (ms) => {
return new Promise(resolve => setTimeout(resolve, ms));
}
const fn = async () => {
await sleep(100); // imagine this was a grpc call or db call etc
a = "important"
}
fn(); // run again but prepend this line with "await"
console.log(`The important data is ${a} ${a === null ? '🚨🚨🚨🚨' : ''}`);