axios({
method: 'post',
url: '/user/12345',
data: { x: 1 }
});
axios.post('/user', { x: 1 })
.then(res => console.log(res))
.catch(err => console.log(err));
{
data: {}, // response that was provided by the server
status: 200,
statusText: 'OK',
headers: {}, // HTTP headers that the server responded with
config: {}, // provided to axios for the request
request: {} //
}
axios.get('/user/12345')
.then(res => {
console.log(res.data);
console.log(res.status);
console.log(res.statusText);
console.log(res.headers);
console.log(res.config);
});
SERVER_ERROR
// server
new ServerError(SEQUELIZE_CONNECTION_REFUSED_ERROR, err.message);
// client
{
status: 404,
errorSpec: {
code: 4002,
name: 'NOT_FOUND_USER',
description: '해당 사용자를 찾을 수 없습니다.'
},
message: '...'
}
{
status:
data:
우리가 원하는 데이터
}
CLIENT_ERROR
API 호출 & handling