So, i'm trying to get static json data through axios and commit it to the "projects" state in vuex, but I'm getting the error "Store.commit is not a function".
Am I missing something?
Do keep in mind that I am doing this in Vue3's vuex.
//store.js
import axios from 'axios';
import { createStore, Store } from 'vuex'
export default createStore({
state: {
projects:[]
},
mutations: {
SET_PROJECTS: (state, projects) => {
state.projects = projects;
}
},
actions: {
},
modules: {
}
});
const getPrjectData = () => {
axios
.get('static json URL here')
.then(response => {
Store.commit('SET_PROJECTS', response.data.projects);
})
.catch(err => console.log(err));
}
getPrjectData();