When i am making a http call with axios it goes in catch block with error My requirement is to handle the 300 response in then block it should not got to catch, how can i achieve that through axios
I think you have multiple choices. You can either extract your code from then callback into function - and call it in error handler when status code is 300.
You could also try this option from axios, to reject the promise only when the status code is > 301.
axios.get('/user/12345', {
validateStatus: function (status) {
return status <= 300; // Reject only if the status code is greater than 300
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With