0👍
You are correct. Whenever the axios
instance receives a response with a statuscode out of the range of 2xx it will throw an error. Reference
You can implement your functionality using the code below.
async inputschedule(){
await axios.post('api/schedule',{
tweet:this.text,
schedule_at:this.data+' '+this.clock
})
.then((response) => {
// Handle success response.
}
.catch((error)=>{
// Check whether the response was received.
if (error.response) {
if (error.response.status == 400){
console.log(error.response.status)
this.error='Il post non può essere pianificato per questa data'
}
}
})
},
- [Vuejs]-Any way to show url-info with $router.push()?
- [Vuejs]-How to pass bata between siblings in vuejs
Source:stackexchange.com