Erro unknown action type: getCourses
[Finalizado Pelo Aluno]
Oi boa tarde, segui os passos dessa aula, mas está dando esse erro no console " unknown action type: getCourses". Dentro de Modules/courses criei os arquivos actions, getters,index,mutations e state. Meu código em actions.js
"import CourseService from "@/services/Course.service";
const actions = {
getCourses({ commit }) {
CourseService.getCourses().then((response) =>
commit("ADD_MY_COURSES", response.data)
);
},
};
export default actions;
"
Meu código dentro de index.js
"import state from "./state";
import mutations from "./mutations";
import actions from "./actions";
import getters from "./getters";
export default {
state,
mutations,
actions,
getters,
};
"
Meu código dentro de mutations
"const mutations = {
ADD_MY_COURSES (state, myCourses) {
state.myCourses = myCourses
},
}
export default mutations"
Dentro de HomeView.vue estou chamando assim
"import { onMounted } from "vue";
import { useStore } from "vuex";
import CardCourse from "./components/CardCourseView.vue";
export default {
name: "HomeView",
setup() {
const store = useStore();
onMounted(() => store.dispatch("getCourses"));
}"
Dentro de Course.service.js estou chamando assim "
import BaseService from "./Base.service";
export default class CourseService extends BaseService {
static async getCourses() {
return new Promise((resolve, reject) => {
this.request({ auth: true })
.get("/courses")
.then((response) => resolve(response.data))
.catch((error) => reject(error.response));
});
}
}
"
Faltou o import dentro do index.js do /store em modules. Consegui resolver.
Precisa estar logado para conseguir responder a este ticket!
Clique Aqui Para Entrar!