Skip to content

Instantly share code, notes, and snippets.

View Kraloz's full-sized avatar
🏠
Working from home

Tomas Aprile Kraloz

🏠
Working from home
  • Buenos Aires, Argentina
View GitHub Profile
@Kraloz
Kraloz / axios-catch-error.js
Created October 31, 2019 20:40 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨