try { await axios.get('/bad-call') } catch (error) { const err = error as AxiosError if (err.response) { console.log(err.response.status) console.log(err.response.data) } this.handleAxiosError(error) }
axios.get('/foo') .catch(function (error) { if (error.response) { console.log(error.response.data); console.log(error.response.status); console.log(error.response.headers); } });
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>