Is it possible for Axios to differentiate between the following:
It seems that in both cases, all we get back is a rather unhelpful "Network Error" message...
The Axios documentation (https://github.com/axios/axios#handling-errors) suggests that in the latter case, error.request
should be populated, but I have been unable to replicate any scenario where error.request
exists. In both of the above scenarios, I get an error object looking like this:
{
config: { ... },
response: undefined,
message: "Network Error",
stack: "Error: Network Error at createError (http://localhost:3000/static/js/bundle.js:1636:15) at XMLHttpRequest.handleError (http://localhost:3000/static/js/bundle.js:1170:14)"
}
I don't know exacly if you can get ERR_CONNECTION_REFUSED but ERR_INTERNET_DISCONNECTED you can get use native web Network Information API,take a look on snippet bellow:
var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
console.log(connection);
When connection.type: "none"
mean that you are ERR_INTERNET_DISCONNECTED
, maybe you can explore this solution.
you can read complete documention here, cya
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