Test getFruits action with fruit-api

This commit is contained in:
2020-12-04 02:26:50 +01:00
parent 4b1ac294bd
commit a027285357
12 changed files with 75 additions and 97 deletions

8
src/store/actions.js Normal file
View File

@@ -0,0 +1,8 @@
import axios from "axios";
export default {
getFruits: async ({ commit }) => {
const response = await axios.get("http://localhost:3000/fruit");
commit("setFruits", response.data.data);
}
};

5
src/store/getters.js Normal file
View File

@@ -0,0 +1,5 @@
export default {
parsedFruits: () => {
return [{ id: 1 }];
}
};

View File

@@ -1,6 +1,8 @@
import Vue from "vue";
import Vuex from "vuex";
import mutations from "./mutations";
import actions from "./actions";
import getters from "./getters";
export const state = {
fruits: [],
@@ -11,5 +13,7 @@ Vue.use(Vuex);
export default new Vuex.Store({
state,
mutations
mutations,
actions,
getters
});