I am making API call using axios in reactjs project but somehow I am not able to catch the error. I am getting 404 but not able to catch it. can somebody tell me what's wrong?
abc.js
export default axios.create({
baseURL: `my_base_url`,
headers: {
"Content-Type": "application/json",
},
});
xyz.js
export const createProcessApiCall = (param) => {
return API.post("/v1/process1", param);
};
zzz.js
const postData = async (param) => {
await createProcessApiCall(param)
.then((response) => {
setApiData(response.data.data);
setIsSuccess(response.data.isSuccess);
})
.catch((e) => {
setIsError(true);
});
};
axiosonly raise error if the error is, let say, network error or such. 404 error, on the other hand, mean that the request was delivered. Read this question