Click here to Skip to main content
15,881,938 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.password)
              .then(cred => {
                  alias: this.alias,
                  cred_id: cred.uid
              }).then(() => {
                  this.$router.push({name: 'welcome'})
              .catch(err=> {
       = err.message

Error occur at this point
cred_id: cred.uid

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!
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.
    alias: this.alias,
    cred_id: cred.user.uid
Share this answer
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