Last active
April 26, 2018 04:07
-
-
Save israeleriston/5222569052a9e62b02872992e61786f1 to your computer and use it in GitHub Desktop.
Commits and Mutations examples vuex
This file contains hidden or 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
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