Hasan Setiawan

Write, write, write give your wings on code!

Follow me on GitHub

Javascript async await with your bare hand

Just show you how does async await work in very simple code

            
async function howAsyncWork() {
	await firstMethod();
	await secondMethod();
	await thirdMethod();
}

function firstMethod() {
	console.log("shoud be called at the first time");
}

function secondMethod() {
	console.log("shoud be called at the second time");
}

function thirdMethod() {
	console.log("shoud be called at the third time");
}

howAsyncWork();

// will print log
VM569:8 shoud called first time
VM569:12 shoud called second time
VM569:16 shoud called third time