D
D
dron1122021-02-17 21:06:41
Vue.js
dron112, 2021-02-17 21:06:41

Vuex Devtools not seeing actions?

I write spa on vue & vuex, I use devtools vue to track the state, but for some reason it shows the state that is changed using mutations, but does not show it using actions. What could be the problem ?

Component

<script>
export default {
  data() {
    return {
      search: '',
      users: []
    }
  },
  methods: {
    async submitHandler() {
      this.$store.commit('test')
      await this.$store.dispatch('fetchUsers', this.search)
      this.search = ''
      this.fetchUsers()
    },
    fetchUsers() {
      this.users = this.$store.state.users
      console.log(this.users);
    }
  }
}
</script>


store
import Vuex from "vuex";
import Vue from "vue";

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        users: []
    },
    actions: {
        async fetchUsers({commit, state}, {req}) {
            const response = await fetch(`https://api.github.com/search/users?q=${req}`)
            state.users = await response.json()
        }
    },
    mutations: {
        test(state){
            state.test = 1
        }
    }
})
<img src="https://habrastorage.org/webt/60/2d/5b/602d5b0e32043433064995.png" alt="image"/>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2021-02-17
@dron112

And it won't show. The state must change in mutation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question