0
백엔드에 koa.js, 프런트 엔드에 http 요청에 axios을 사용하고 있습니다. 나는 koa.js에서 오류 메시지를 설정하고 프런트 엔드에서 오류 메시지 싶지만 koa.js + axios로 오류 메시지 받기
koa.js API 호출 "요청은 상태 코드 500로 실패"단지 기본 오류 메시지가
Axios의와module.exports.addIntr = async (ctx, next) => {
const intrObj = ctx.request.body;
try {
intrObj = await compileOneInterest(intrObj);
ctx.response.body = intrObj;
} catch (err) {
const statusCode = err.status || 500;
ctx.throw(statusCode, err.message);
}
};
HTTP 요청
export function addInter(interObj) {
return (dispatch) => {
const url = `${API_ADDRESS}/ep/${10}/intr/`;
axios({
method: 'post',
url,
data: interObj,
// params: {
// auth: AccessStore.getToken(),
// },
})
.then((response) => {
dispatch(addIntrSuccess(response.data));
})
.catch((error) => {
dispatch(handlePoiError(error.message));
console.log(error.response);
console.log(error.request);
console.log(error.message);
});
};
}
,
위대한 답변, 고맙습니다. – Matt