Axios api call doesn't accept parameters

I am trying to pass the following information to my dispatch function but the values are simply not begin recognized for some reason. They usually come out as undefined

My disptach call in my component:

  methods: {
    buscar(){
      const formData = {
        user: this.user,
        password: this.password,
        profile: this.profile
      };
      console.log('fomrdata: ',formData)
      this.$store.dispatch('login', formData)
    }
  },

My method in store:

login(formData) {
  console.log(formData)
 },

All the values exist when i fill in my form and they show up in my component's console.log().

Upvotes: 0

Views: 67

Answers (1)

Rich
Rich

Reputation: 562

formData should be the second parameter in the action.

actions: {
    login ({ commit }, formData) {
        console.log(formData);
    }
}

Upvotes: 3

Related Questions