[Vuejs]-VueJS emit not working in after store dispatch

-1👍

Please check the content of "this" – i think you won’t find any content you’d expect, when you’re inside the promise.

This should help you out:

let tempThis = this;
...
.then((res) => {
            tempThis.$emit('closeModal'); //<-- This line does work now

keep in mind that you could also use async/await (ES6) here, where this "problem" does not occur but you’d have to check the status of the response yourself so it would otherwhise not be that much easier to read or anything

👤OnFire

Leave a comment