import { createStore } from "vuex";
const { store } = createStore({
state: {
curs: [],
},
mutations: {
SET_CURS_TO_STATE: (state, curs) => {
state.curs = curs;
}
},
actions: {
async GET_CURS_FROM_API({commit}) {
try {
const curs = await axios('http://localhost:3000/cursdata', {
method: "GET"
});
commit("SET_CURS_TO_STATE", curs);
} catch (error) {
console.log(error);
}
}
},
getters: {
UPDATA_CURS(state) {
return state.curs
}
}
});
export default store;
import { createApp } from 'vue'
import * as Vue from 'vue'
import App from './App.vue'
import './index.css'
import router from "./router"
import store from './vuex/store';
createApp(App).use(router, store).mount('#app')
const { store } = createStore({
.use(router, store)