I'm trying to figure out an accurate way to detect axios call failure due to no internet connection.
Does axios call failure return a specific response object or specific response status code or throw a specific error details for the no internet connection scenario?
Example of what i will use the "detection of axios failure due to no internet connection" for
try {
const res = await server.get('/auth/user?', {
params: {
refreshToken: refreshToken,
userID: userID
}
}
);
if(res.user.data){
dispatch({type: LOGIN_USER_SUCCESS, payload: res.data.user});
} else {
if(res.axiosFailsDueToNoInternetConnection){
alert('no internet connection');
dispatch({type: RELOAD});
}
}
} catch (error) {
if(error.dueToNoInternetConnection){
alert('no internet connection');
dispatch({type: RELOAD});
}
}