dimanche 8 octobre 2017

Firebase retrieves snapshot value as null

I use the .once( function in Firebase and am successfully retrieving the snapshot.key NAME of the directory. But this key has also a value. When requesting snapshot.val() also gives out null despise it having a value. The database looks like this:

    stages {
    stage1 : "values i want to get"
    stage2 : "values i want to get"
    stage2 : "values i want to get"
    stage2 : "values i want to get"
    }


    var ref = "stage1";
    var branch = firebase.database().ref(ref).once('value').then(function(s){
    console.log(s.key); // GIVES THE CORRECT ANSWER
    console.log(s.val()); //GIVES null ... doesn't give me the "values i want.."

Am i doing it completely wrong? I'm new to Firebase. Please know that the database is structured like this intentionally

Aucun commentaire:

Enregistrer un commentaire