Answer the question
In order to leave comments, you need to log in
VueJS Mutations and Actions - payload object not being passed, why?
There are three users.
users: [
{id: 1, name: "Andrey", registered: false},
{id: 2, name: "Ivan", registered: false},
{id: 3, name: "Max", registered: false}
]
methods: {
register(user) {
console.log('in method user id = ', user.id)
this.$store.dispatch('register', {
payload: {
type: 'register',
user
}
})
}
}
register({commit}, payload) {
commit('register', payload)
}
register(state, payload) {
const user = state.users.find(user => {
return user.id === payload.user.id
})
user.registered = true;
const registration = {
userId: payload.user.id,
name: user.name
}
state.registrations.push(registration)
}
const user = state.users.find(user => {
return user.id === payload.user.id
})
Answer the question
In order to leave comments, you need to log in
The question is closed, I blunted it myself ...
The error was in this code:
this.$store.dispatch('register', {
payload: {
type: 'register',
user
}
})
this.$store.dispatch('register', {
type: 'register',
user
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question