export const state = () => ({ heroes: [] }) export const actions = { async fetchHeroes({state, commit}) { const heroes = await this.$axios.$get('/api/v1/product-heroes') if(heroes.isAxiosError === true){ console.log(heroes.data) return Error('') } commit('setHeroes', heroes) return state.heroes }, async activateHero({commit}, heroId) { const activeHero = await this.$axios.$patch(`/api/v1/product-heroes/${heroId}`) if(activeHero.isAxiosError === true){ console.log(activeHero.data) return Error('') } commit('hero/setHero', activeHero, {root: true}) return activeHero } } export const mutations = { setHeroes(state, heroes) { state.heroes = heroes } }