Skip to content

Instantly share code, notes, and snippets.

@mercs600
Created April 5, 2020 16:23
Show Gist options
  • Save mercs600/610b0ce59d241f2004e9cb1a06500a79 to your computer and use it in GitHub Desktop.
Save mercs600/610b0ce59d241f2004e9cb1a06500a79 to your computer and use it in GitHub Desktop.
nuxt-exercise-6-store-actions
export const actions = {
async nuxtServerInit ({ commit }, { $http }) {
const menu = await $http.$get('api/menu')
commit('setMenu', menu)
}
}
export const state = () => ({
menu: []
})
export const mutations = {
setMenu(state, payload) {
state.menu = payload
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment