In this chapter we will show you how to read Firebase data.
The following image shows the data we want to read.
We can use on() method to retrieve data. This method is taking event type "value" and retrieves snapshot of the data. When we add val() method to snapshot, we will get Javascript representation of the data.
In our next chapter, we will explain other event types that you can use for reading data.
The following image shows the data we want to read.
We can use on() method to retrieve data. This method is taking event type "value" and retrieves snapshot of the data. When we add val() method to snapshot, we will get Javascript representation of the data.
Example
var ref = firebase.database().ref(); ref.on("value", function(snapshot) { console.log(snapshot.val()); }, function (error) { console.log("Error: " + error.code); });If we run the following code, our console will show the data.
In our next chapter, we will explain other event types that you can use for reading data.
No comments:
Post a Comment