this
is undefined and do not point to the Vue component instance inside then
method. Following is the code
import { mapActions, mapMutations, mapGetters } from "vuex";
data: () => ({
id: null,
title: "",
description: ""
}),
computed: {
...mapGetters("post/poststore", ["getPostDetails"])
},
methods: {
...mapActions({
postAction: "post/postAction"
}),
post() {
this.postAction({
id: this.id,
title: this.title,
description: this.description
})
.then(function(data) {
if (data) {
if (this.getPostDetails.postType == "article") { // **this** here is undfeined
// Do something
} else {
// Do something
}
}
})
}
}