Tufail Ahmad
Tufail Ahmad

Reputation: 396

How can I get array from child in the JavaScript firebase sdk from database

Here is my database Image.

I want to display all the values in the vertex. How can I do this? Currently the following code give me null value.

var dbRef = firebase.database().ref("data/aqibkhan109").child('corn').child('polygon19').child('vertex');

        dbRef.on('value', function(snapshot){
          console.log(snapshot.val());
        });

Any help Please, It's a realtime database

Upvotes: 0

Views: 451

Answers (3)

Mohd Talha
Mohd Talha

Reputation: 1

var dbRef = firebase.database().ref().child("Data/aqibkhan109/corn/polygon19/vertex");
dbRef.on('value',snapshot=>{
console.log(snapshot.val());
});

Try this. I hope it will work for you.

Upvotes: 0

Peter Haddad
Peter Haddad

Reputation: 80914

Change this:

ref("data/aqibkhan109")

into this:

ref("Data/aqibkhan109")

data should use capital letter same as in the database.

Upvotes: 1

Doug Stevenson
Doug Stevenson

Reputation: 317372

The first node of your database is "Data" with a capital D, but your code is using "data" with a lowercase d. The database is always case sensitive, and queries need to match exactly.

Upvotes: 1

Related Questions