Skip to content

Instantly share code, notes, and snippets.

@M1cr0M1nd
Created May 29, 2019 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save M1cr0M1nd/ab170be22d15db5dc3dc2a934878553a to your computer and use it in GitHub Desktop.
Save M1cr0M1nd/ab170be22d15db5dc3dc2a934878553a to your computer and use it in GitHub Desktop.
Intro to the Vue State Manager - Vuex
const store = new Vuex.Store({
state: {
score: 0
},
mutations: {
SET_SCORE (state, value) {
state.score = value
}
},
actions: {
async setScore ({ commit }) {
let { data } = await Axios.post('http://scoresrus.com/getScoreApi')
if (data.status == 200) {
commit('SET_SCORE', data.data.score)
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment