How i can get all data from hotel to cant print the data to console, to be able to print in this way the data
"nombre, rfc, infGen,ubicacion"
How i can get all data from hotel to cant print the data to console, to be able to print in this way the data
"nombre, rfc, infGen,ubicacion"
You can also use the Firebase REST API if the realtime reference syntax is throwing you off. Using an AJAX library (I will use axios for the example), you can easily read data from your database.
Below are some examples on how to read data from Firebase.
// This first call will return the root of your database
// By appending the url with '.json', the response will be JSON
axios('https://**your-database-here**.firebaseio.com/.json')
.then(response => {
// Using .then to access the resolved data from the promise
// "response" itself is an object, but our data is assigned to the data property
console.log(response.data);
});
// This call will return a single collection, such as the Hotel collection.
// Be aware that firebase does not return array, but instead returns an object of key - value pairs
axios('https://**your-database-here**.firebaseio.com/Hotel.json')
.then(response => {
console.log(response.data);
var hotel = response.data; // Again, just wait the actual data
// Will need to loop over object to get nested data here
});
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
foreach is the operation that need, this get data one by one
var query = firebase.database().ref("Hotel/"+usuario.uid);
query.once("value")
.then(function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var hrfc = childSnapshot.val().RFC;
var hnombre = childSnapshot.val().nombre;
var hinfo = childSnapshot.val().infoGen;
var hubic = childSnapshot.val().ubicacion;
});
});
}