Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I write this code but not working

var uid = firebase.auth().createUserWithEmailAndPassword(this.email , this.password)
              .then(cred => {
                ref.set({
                  alias: this.alias,
                  cred_id: cred.uid
                })
              }).then(() => {
                  this.$router.push({name: 'welcome'})
                })
              .catch(err=> {
                console.log(err)
                this.feedback = err.message
              })


Error occur at this point
cred_id: cred.uid


Error
Quote:
Function DocumentReference.set() called with invalid data. Unsupported field value: undefined (found in field cred_id)



What I have tried:

How we can solve that error. Please help!
Posted
Updated 2-Apr-20 5:36am

1 solution

Read the documentation:

createUserWithEmailAndPassword[^] returns a UserCredential[^] object.

The UserCredential doesn't have a property called uid

It does have a property called user, which returns a User[^] object.

The User class has the uid property.
ref.set({
    alias: this.alias,
    cred_id: cred.user.uid
})
 
Share this answer
 
v2
Comments
Member 14088544 3-Apr-20 6:30am    
thanks sir, its working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900