async / await အကြောင်း

ဘာညာ သာဓက

async ကို function parentheses ရှေ့မှာ ထားရမယ်။

Anonymous Function

async function (){}

Arrow Function

const foo = async() => {
}

Function

async function foo(){
}

await ကို ကြာမဲ့ operation ရှေ့မှာ ထားရမယ်။

const foo = await readDatabase(NSA.information);

သူ့ကို ခေါ်သုံးချင်တဲ့အခါမှာ then နဲ့ ခေါ်ရမယ်။

foo().then(data => {
console.log(data);
});

Don’t follow me. I wrote junks here. Follow me on Twitter instead.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store