Skip to content

Commit

Permalink
feat(VueX store): add getters and setters
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Sep 30, 2022
1 parent 009650d commit c4e85fd
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@ export const state = () => ({
version: 0,

statistics: {
timesTheAppHasBeenOpened: 0,
},
timesTheAppHasBeenOpened: 0
}
})

export const getters = {
getVersion() {
return state.version
},

getTimesTheAppHasBeenOpened(state) {
return state.statistics.timesTheAppHasBeenOpened
},
}
}

export const mutations = {
setVersion(state, value) {
state.version = value
},

setTimesTheAppHasBeenOpened(state, value) {
state.statistics.timesTheAppHasBeenOpened = value
},
}
}

export const actions = {
Expand All @@ -28,13 +36,13 @@ export const actions = {
async simpleApiFetch({ state, dispatch }, { url, options }) {
const AXIOS_OPTIONS = {
headers: {
Authorization: this.$auth.strategy.token.get(),
},
Authorization: this.$auth.strategy.token.get()
}
}

return await dispatch('simpleFetch', {
url,
options: { ...options, ...AXIOS_OPTIONS },
options: { ...options, ...AXIOS_OPTIONS }
})
},
}
}

0 comments on commit c4e85fd

Please sign in to comment.