In my mutations.js file, I happen to have one function calling another function in the same file. Here's my sample code example:
export default {
async addQuestionAnswer(state, payload) {
alert(payload);
this.updateSubjects(state);
alert("This is never reached");
},
updateSubjects(state) {
alert("This is never reached");
},
}
Does anyone know how to call the updateSubjects function from the addQuestionAnswer function? I've checked my console.log and found this error:
Uncaught (in promise) TypeError: _this.updateSubjects is not a function
Thanks @kissu, I've found the solution to my problem based on the console.log error I've posted with your suggestion. Thanks. I added this to my mutations.js file:
import store from '../store';
Then I changed this:
this.updateSubjects(state);
To this:
store.commit("updateSubjects");
And it works! :-)