L
L
Little Vasya2019-01-15 22:57:08
Vue.js
Little Vasya, 2019-01-15 22:57:08

Parameter not working in vuex?

Why does the passed argument work so strangely?
5c3e3af99377b693390875.png
the code itself

const actions = {
  async fetchUserSignIn (password, phoneNumber) {
    const user = await authApi.fetchUserSignIn(password, phoneNumber)
    return user
  }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
akass, 2019-01-16
@emilov

const actions = {
  async fetchUserSignIn ({ commit }, { password, phoneNumber }) {
    const user = await authApi.fetchUserSignIn(password, phoneNumber)
    commit('commit_user_mutation' , user);
  }
}

A
Alexander Aksentiev, 2019-01-15
@Sanasol

because the first argument to the action is the entire state/context of your store.
And you need to commit mutations to it, and not just what you have heaped up here, it doesn’t work that way at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question