export const state = () => ({
  item: {}
})


export const actions = {
  async createHero({commit, state}, courseHeroData) {
    const hero = await this.$axios.$post('/api/v1/product-heroes', courseHeroData)
    if(hero.isAxiosError === true){
      console.log(data.data)
      return Error('')
    }
    commit('setHero', hero)
    return state.item
  },
  async fetchHero({commit, state}) {
    const data = await this.$axios.$get('/api/v1')
    if(data.isAxiosError === true){
      console.log(data.data)
      return Error('')
    }
    const { productHero } = data
    commit('setHero', productHero)
    return state.item
  }
}

export const mutations = {
  setHero(state, hero) {
    state.item = hero
  }
}