async / await အကြောင်း

Cing Sian Dal
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);
});

--

--

Cing Sian Dal
Cing Sian Dal

Written by Cing Sian Dal

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

No responses yet