Simple question I hope you good people can help me with.
I'm using Firebase and I can display my firebase data on the page using:
var dbRef = firebase.database().ref().child('jumbotron/header');
dbRef.on('value', snap => container.innerText = snap.val());
But when I try to: console.log(dbRef)
It displays as an object. I think this is because the reference is a URL. How can I console.log or print my firebase data as a string and eventually place it on my page using vanilla javascript. I can't find the solution in the FB documentation and there aren't any tutorials on the Google FB.
Any help is much appreciated. Thanks, All
As the name implies dbRef
is a reference to the data, it is not the data itself.
When you attach a listener to the reference with on()
, you will get a snapshot of the data at that location. You can get the value from this snapshot and print it:
var dbRef = firebase.database().ref().child('jumbotron/header');
dbRef.on('value', snapshot => {
console.log(snapshot.val());
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With