0๐
You can simply wrap an api call into try-catch and simply donโt to do anything with e
in catch part.
try { ... you code here ... } catch(e){}
0๐
If you are using Axios for API calls you can create a global interceptor and return a response based on your status code to your component.
This would go in your main.js.
axios.interceptors.response.use(null, function(error) {
console.log(error);
if(err.response.status === 406){
//your code here.
}
return Promise.reject(error);
});
0๐
you can wrap your call in a try{} catch(e) {}
to handle what happens after the error happens
but it is impossible to prevent the browser from showing the error in the console programmatically because of the potential risk that a script might misuse the errored requests to hide its activities from the user.
- [Vuejs]-What is proper component composition and use of props in Vue.js?
- [Vuejs]-How can I use webcomponents in a Vue application using Typescript
0๐
check_time(day,hour){
var fields = {};
fields.day = parseInt(day);
fields.hour = parseInt(hour);
try {
this.$http.post('courses/check', fields)
} catch {
this.$store.dispatch('alert', {'message': 'Already exist a course in this interval.'});
}
}
Source:stackexchange.com