Vuex actions not working properly. Shows an error "signInWithEmailAndPassword failed: First argument "email" must be a valid string"

Viewed 208

Im new in Vuejs state management. I tried to make a login system with Firebase using Vuex. But getting this error.

signInWithEmailAndPassword failed: First argument "email" must be a valid string

Cant understand where is the problem.

<pre>
//  store/auth.js

export const actions = {
    loginUser(payload){
        firebase.auth().signInWithEmailAndPassword(payload.email, payload.password)
        .then(user => {           
            console.log(user);
        })
        .catch(error => {
            console.log(error);            
        }) 
    }
}


// Login.vue

export default {
    data(){
      return{
        email:'',
        password:''
      }
    },
    methods:{
      login(){
        this.$store.dispatch('auth/loginUser', {email:this.email, password:this.password})
      }
    }
}
</pre>   

// Form

<v-flex xs12>
                  <v-text-field
                    v-model="email"                           
                    name="email"
                    label="Email"
                    type="email"
                    required></v-text-field>
                </v-flex>
              </v-layout>

              <v-layout row>
                <v-flex xs12>
                  <v-text-field
                    v-model="password"                               
                    name="password"
                    label="Password"
                    type="password"
                    required></v-text-field>
                </v-flex>
              </v-layout>
1 Answers
Related