Topic: Set toast v-model to true in axios .catch

aceracerff priority asked 2 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;
    });
},

Mikołaj Smoleński staff commented 2 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



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Opened

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Vue
  • MDB Version: MDB5 1.3.0
  • Device: Windows PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No
Tags