Topic: Set toast v-model to true in axios .catch
aceracerff premium priority asked 3 years ago
Hello,
I was hoping to use Toast to display an error message for bad axios call. Setting the toast's v-model to true inside of an axios .catch causes it to never go away, and the 'X' does not work. I understand this may be an axios thing and not a MDB thing, but does anyone know of a way to fix this?
Relevant code:
setup() {
const toast = ref(false);
return { toast };
},
methods: {
doThing() {
axios.post("url", {
//obj
})
.then((r) => {
//do stuff
})
.catch((e) => {
this.toast = true;
});
},
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Open
- User: Free
- Premium support: No
- Technology: MDB Vue
- MDB Version: MDB5 1.3.0
- Device: Windows PC
- Browser: Chrome
- OS: Windows 10
- Provided sample code: No
- Provided link: No
Mikołaj Smoleński staff commented 3 years ago
Did you try to use composition API? It can be one of the possible reasons of such issue. Mixing new ref Vue 3 syntax with old Options API Vue 2 syntax is not recommended.
Keep coding, Mikołaj from MDB