Is it possible for Axios to distinguish between the following:
- A request that is not executed because the client does not have a network connection at the time the request was made - (ERR_CONNECTION_REFUSED).
- A request that is not executed due to loss of network connection after the request is completed, but before it is received, is (ERR_INTERNET_DISCONNECTED).
It seems that in both cases, all we get is a rather useless "Network Error" message ...
The Axios documentation ( https://github.com/axios/axios#handling-errors ) suggests that in the latter case it should be populated error.request
, but I could not reproduce any script in which it exists error.request
. In both of the above scenarios, I get an error object similar to 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)"
}
source
share