Search code examples
javascriptreactjsfirebasereactfire

Cannot retrieve firebase json from database using reactFire


I am tring to connect to my firebase using reactFire

This is my root of json "glossary"

var firebaseRef = firebase.database().ref('/glossary');
console.log(firebaseRef)

But when in console if get the following

U {k: Bh, path: K, n: ce, bc: false}
bc
:
false
k
:
Bh
n
:
ce
path
:
K
__proto__
:
Y

Solution

  • A reference to a database location does not yet have the actual data at that location. To get the data, you will need to listen for it. For example:

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

    Note that this is all covered in the Firebase documentation. I highly recommend you spend some time there.