I'm developing an application and I want to use the status code 400 when a user sends invalid or incomplete data, but when axios receives a 400 status code it throws an error and I can't get the response from it, it just gives me a error that includes the request but not the response, how am I supposed to handle this?
const getIdTypes = () => {
return axios_instance.get
(idTypesUrl)
}
const getValidIdTypes = async () => {
return infoActions.getIdTypes()
.then(res => {
if (res.status !== 200 && res.status !== 201) {
pushToFlasher(res.data)
}
setValidIdTypes(res.data)
})
.catch(err => {
if (err.request) {
console.log("err:", err.request)
}
if (err.response) {
console.log("err:", err.response)
}
// pushToFlasher(err.response.data)
})
}