aboutsummaryrefslogblamecommitdiff
path: root/client/src/store/index.js
blob: d2fe9b7886f9d3e9e7e48f1d9a743f475585fa6f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                                


                            





                            

              


                                  

            




                                                                       



            
import {createStore} from 'vuex'
import axios from 'axios';

export default createStore({
  state: {
    products: []
  },
  getters: {
    getProducts(state) {
      return state.products;
    }
  },
  mutations: {
    setProducts(state, products) {
      state.products = products;
    }
  },
  actions: {
    async pullProducts(context) {
      await axios.get(`${process.env.VUE_APP_ROOT_API}/products`)
        .then(response => context.commit('setProducts', response.data))
        .catch(error => console.error(error));
    }
  },
  modules: {
  }
})