JavaScript async ์ await
async.awaitโโ
promise๋ฅผ ์ข ๋ ๊ฐํธํ๊ณ ๋๊ธฐ์ ์ผ๋ก ์คํ๋๋๊ฒ์ฒ๋ผ ๋ณด์ด๊ฒ ๋ง๋ค์ด์ฃผ๋๊ฒ
async
// async & await
// clear style of using promise :)
// promise๋ฅผ ์ข ๋ ๊น๋ํ๊ฒ ์ฌ์ฉํ๊ฒ ๋ง๋ค์ด์ค
// 1.async
async function fetchUser() {
//do network reqeust in 10 secs....
return 'ellie';
}
// async ๋ผ๋ ํค์๋๋ฅผ ์ฌ์ฉํ๋ฉด promise๋ ๋๊ฐ์ ๊ธฐ๋ฅ์ ์ํํจ
const user = fetchUser();
user.then(console.log);
console.log(user);await
useful promise APIs
Last updated
Was this helpful?