-
-
Save M1cr0M1nd/ab170be22d15db5dc3dc2a934878553a to your computer and use it in GitHub Desktop.
Intro to the Vue State Manager - Vuex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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