try catch axios code example
Example 1: axios call error handling
axios.get('/api/xyz/abcd')
.catch(function (error) {
if (error.response) {
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
console.log(error.request);
} else {
console.log('Error', error.message);
}
});
Example 2: vue axios catch error
axios.get('/user/1').then((response) => {
console.log('Everything is awesome.');
}).catch((error) => {
console.warn('Not good man :(');
})