Skip to content

Instantly share code, notes, and snippets.

@douggrubba
Created Aug 28, 2021
Embed
What would you like to do?
user.js
// initial state
const state = () => ({
user: {}
})
// getters
const getters = {
getUser: state => {
return state.user
}
}
// actions
const actions = {
setUserData({ commit }, user) {
commit('setUser', user)
}
}
// mutations
const mutations = {
setUser(state, user) {
state.user = user
}
}
export default {
namespaced: true,
state,
getters,
actions,
mutations
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment