vue js axios error handling
axios.get('/user/1').then((response) => {
console.log('Everything is awesome.');
}).catch((error) => {
console.warn('Not good man :(');
})
3.86
8
new Vue({
el: '#app',
data () {
return {
info: null,
loading: true,
errored: false
}
},
filters: {
currencydecimal (value) {
return value.toFixed(2)
}
},
mounted () {
axios
.get('https://api.coindesk.com/v1/bpi/currentprice.json')
.then(response => {
this.info = response.data.bpi
})
.catch(error => {
console.log(error)
this.errored = true
})
.finally(() => this.loading = false)
}
})
Thank you!
8
0
Are there any code examples left?
New code examples in category Javascript