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