-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Hello, when i'm trying to use the store I have this error
proxy.js?fe19:354 Uncaught (in promise) TypeError: commit is not a function
here my code
import { action, createModule, mutation } from 'vuex-class-component';
import { Country } from '@/interfaces/country';
import { CountriesAdapter } from '@/adapters/countries.adapter';
import axios from 'axios';
const VuexModule = createModule({
namespaced: 'Countries',
strict: false,
});
export class CountriesStore extends VuexModule {
private countries: Country[] = [];
@mutation
clear() {
this.countries = [];
}
@mutation
setCountries(payload: Country[]) {
this.countries = payload;
}
@action
async getCountries(forceRefresh = false) {
const { data } = await axios.get(`${process.env.VUE_APP_COUNTRIES_API_URL}/countries`);
const response = CountriesAdapter.get(data);
this.setCountries(response);
return response;
}
// Explicitly define a vuex getter using class getters.
get getCountriesList() {
return this.countries;
}
}
And in my component
mounted() {
this.$store.dispatch('Countries/getCountries');
}
I don't where is the problem.
michael-scheurer
Metadata
Metadata
Assignees
Labels
No labels