I have an api service like this:
api.interceptors.response.use(
(response: any) => {
console.log("response",response)
if (response.status === 200) {
response = response.data['data'] ?? response.data;
}
return response
},
(error) => {
// TODO handle errors
const code = parseInt(error.response && error.response.status)
const data = error.response.errors;
if (code === 404) {
console.log("error",error)
data.forEach(itemError => {
toast.error(itemError, {
theme: 'colored',
});
});
}
}
)
but server send to me response message when error code is 404. how I can access to this data?
for example this is a response of 404 server error:
{"status":false,"message":"bad request!","errors":["invalid otp code"],"data":null}