index.js 426 B

123456789101112131415161718192021
  1. export const state = () => ({
  2. heroes: []
  3. })
  4. export const actions = {
  5. async fetchHeroes({state, commit}) {
  6. const heroes = await this.$axios.$get('/api/v1/product-heroes')
  7. if(heroes.isAxiosError === true){
  8. console.log(data.data)
  9. return Error('')
  10. }
  11. commit('setHeroes', heroes)
  12. return state.heroes
  13. }
  14. }
  15. export const mutations = {
  16. setHeroes(state, heroes) {
  17. state.heroes = heroes
  18. }
  19. }