I am trying to understand the asnyc await functionality. Therefore, i want to use an asnyc function, resolve it and do the following logs sequentially afterwards.
How do I achieve this? Or am I understanding something fundamentally wrong?
const test = async function() {
console.log('hi 1');
await setTimeout(() => {
console.log('timout1')
}, 1000);
console.log('hi 2');
console.log('hi 3');
}
test()
Result
hi 1
hi 2
hi 3
timout1
Expected Result
hi 1
timout1
hi 2
hi 3