Skip to content

Instantly share code, notes, and snippets.

@lgugliotta
lgugliotta / axios-catch-error.js
Created May 10, 2022 12:25 — 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 😨