//接口
getData (url, params) {
return axios.get('/user?id=123')
}
//方法名前加 async
async function getUser() {
try {
//调用接口名前加 await
const response = await getData(url, params);
console.log(response);
} catch (error) {
console.error(error);
}
}
상기 인터페이스 이름 앞에 비동기 플러스 AWAIT의 첨가 이전에있어서,하지 않도록하는 비동기 호출한다.