[Vuejs]-Cannot access vuex state inside a function

0👍

The action addCategory is async so that’s why you should await it before checking this.validationErrors

 async handleSubmit() {
      await this.addCategory(this.category);

      console.log(this.validationErrors); // returns `null` on first submit
    }

OR

 handleSubmit() {
      this.addCategory(this.category),then(() => {
         console.log(this.validationErrors); // returns `null` on first submit
      });
    }

Leave a comment