Skip to content

Instantly share code, notes, and snippets.

@fgilio
fgilio / axios-catch-error.js
Last active December 19, 2024 06:25
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 😨