diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/store.js | 15 | ||||
-rw-r--r-- | src/views/Home.vue | 10 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/store.js b/src/store.js index 0e96ac7..9080bd0 100644 --- a/src/store.js +++ b/src/store.js @@ -8,9 +8,24 @@ export default new Vuex.Store({ 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: { } diff --git a/src/views/Home.vue b/src/views/Home.vue index 55c3c08..28da86b 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,6 +1,8 @@ <template lang="pug"> main header-blue + b-container + h2 List of commits </template> <script> @@ -10,6 +12,14 @@ export default { name: "Home", components: { 'header-blue': HeaderBlue, + }, + mounted() { + this.$store.dispatch('get_commits'); + }, + computed: { + commits: () => { + return this.$store.get.commits; + } } } </script> |