What happens if an Axios GET request fails due to a network error (e.g., no internet connection)?

Responsive Ad Header

Question

Grade: Education Subject: Support
What happens if an Axios GET request fails due to a network error (e.g., no internet connection)?
Asked by:
97 Viewed 97 Answers

Answer (97)

Best Answer
(333)
In case of a network error, `error.response` will be `undefined`. The `error.message` will typically indicate a network-related issue, such as 'Request failed with status code 408' or 'Network Error'. You should handle this scenario separately, informing the user about the network problem and suggesting they check their connection.