I'm using async await with axios and am having trouble with the error handling. Using normal promises (example 2 below), I can get an error object when killing my local server. However, using async await, the error comes in as undefined (example 1 below) Does anyone know why this would be
const instance = axios.create({
baseURL: 'http://localhost:8000',
timeout: 3000,
})
// example 1
try {
await instance.get('/data/stores')
} catch (error) {
console.log(error) // error is not defined
}
// example 2
return instance.get('/data/stores').catch(error => {
console.log(error) // error is normal axios error
})