Q:

Get UID and insert in object in database firebase Angular 6

I need to get UID that user created in Authentication and insert this UID in item created in Database Firebase, firt I create user in my auth.ts
createUser(user: any, path: string) {
return this.afu.auth.createUserWithEmailAndPassword(user.email, user.password)
                            .then((res) => { 
                              let id = res.uid;
                              this.teste(id, path);
                              return this.service.save(user, path)
                            });
}

in this service I'll send to another service to create one object relationship him now my userService.ts, so how to get this UID and insert in user/id atribute?
save(user: any, path: string) {
return new Promise((resolve, reject) => {
    return this.db.list(this.PATH + path)
            .push(user)
            .then(() => resolve())
   })
}

A:

If I hope I did not understand your question wrong.
Like mentioned here https://firebase.google.com/docs/auth/web/manage-users
var user = firebase.auth().currentUser;
var name, email, photoUrl, uid, emailVerified;

    if (user != null) {
      name = user.displayName;
      email = user.email;
      photoUrl = user.photoURL;
      emailVerified = user.emailVerified;
      uid = user.uid; 
    }

Now you got your current user's id.
now insert it to your table: 
ref.child("something"+count).set({
  uid: this.uid,
  email: this.email,
  //and more
});

count stands for the id of the object for example:
{
  "0": {
      "uid": "22",
      "email": "something@gmail.com"
    },
   "1": {
      "date_of_birth": "33",
      "full_name": "anothersomething@gmail.com"
    }
} 

is your corresponding json file when you ask for something table.

