에러문 전체 리스폰스 확인하기

Column
status 외에 전체 리스폰스 확인하기
Tags
error

axios api 에러문 전체 리스폰스 확인하기

기본적으로 axios.api → then & catch에서 에러 status일 시 catch에서 잡히는데,
.catch((err)=>console.log("axios error : ", err);
이렇게 출력하면 에러 상태 메세지만 출력된다.
 
리스폰스 전체를 조회하고 싶으면 err.response를 출력하면 된다.
.catch( (error) => { console.log("에러문", error); console.log("에러 리스폰스 전체", error.response); console.log("에러 바디", error.response.data); } )
notion image
 
등록된 기기 개수가 초과됐을 때 403으로 반환하되 바디에 기기 정보를 보내주기로 협의한 상태이므로 바디 확인이 필요했다.