async/await
async function getUser(id) {
const res = await fetch('/api/user/'+id);
return res.json();
}콜백·then 체인 대신 동기처럼 읽히는 비동기 코드.
JavaScript 비동기 문법. Promise의 syntactic sugar.
async function getUser(id) {
const res = await fetch('/api/user/'+id);
return res.json();
}콜백·then 체인 대신 동기처럼 읽히는 비동기 코드.