async / await အကြောင်း
1 min readApr 5, 2020
ဘာညာ သာဓက
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);
});