summaryrefslogtreecommitdiff
path: root/src/store.js
blob: 9080bd002275770afc295a63ab0d478015c0b21f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    api: process.env.VUE_APP_BACKEND_URL,
    commits: [],
  },
  get: {
    commits: state => {
      return state.commits
    },
  },
  mutations: {
    load_commits: (state, value) => {
      state.commits = value
    },
  },
  actions: {
    // Get all commits from the api backend
    async get_commits({commit}) {
      await fetch(`${this.state.api}/commit/`)
        .then(async response => {
          commit('load_commits', await response.json());
        })
    },
  },
  modules: {
  }
})