Skip to content

Instantly share code, notes, and snippets.

@israeleriston
Last active April 26, 2018 04:07
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 israeleriston/5222569052a9e62b02872992e61786f1 to your computer and use it in GitHub Desktop.
Save israeleriston/5222569052a9e62b02872992e61786f1 to your computer and use it in GitHub Desktop.
Commits and Mutations examples vuex
import service from './service-http'
const SET_USER = 'user/SET_USER'
const state = {
user: ''
}
const actions = {
loadUser (context, payload) {
// here layer service between communication backend and frontend
service.getByUser(payload)
.then(data => {
context.commit(SET_USER, data)
})
}
}
const mutations = {
[SET_USER](state, user) {
state.user = user
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment