For API call I have implemented axios it’s working properly for the http status 200 and 400 series as expected but for the 500 series errors iam getting error as undefined in catch block.
Note: need to capture the http status and need to fire the next subsequent calls accordingly. And for 502 there won’t be any response but need to capture the http status.
This is the syntax iam using:
return axios.request(
{url,params, method, other details})
.then((response) => response,
(error) => error && error.response))
. catch((error) => error)
Here for 200 it’s going inside then and response
And for 400 it’s going inside then error
For 502 it’s going inside catch with error as undefined.
I got to know that promise is getting rejected and it’s not being captured. Is there any way to capture the rejected promise?
7