Get a value with column name in Ionic 3 with FireBase

I used the following code block to fetch only a row of data;

db.database.ref('/User/').orderByChild('uID').equalTo(this.uID).once('value', (snapshot) => {
    console.log(snapshot.val());
})

Here is the output;

Ekran%20Al%C4%B1nt%C4%B1s%C4%B1

But if I wanted to get email value like this;

db.database.ref('/User/').orderByChild('uID').equalTo(this.uID).once('value', (snapshot) => {
    console.log(snapshot.val().email);
})

It says this value is undefined.

You can do 1 or more of at least these 3 options.

  1. Use angularFire2 to greatly simplify
  2. Create a custom interface to assign that value to
  3. snapshot.val()['email']

I recommend combining 1 and 2

db.database.ref('/User/').orderByChild('uID').equalTo(this.uID).once('value', (snapshot) => {
        snapshot.forEach(function(child) {
          ...
          return false;
        });
      })

This works fine

I posted the solution, thanks :slight_smile: