I don´t have a lot of programming experience, and I´m trying to solve the following: Given this data structure using Realtime Database Data Structure I want to show in an HTML table the value of the "propina"
key, but not the identifier that the Realtime Database generates.
Up until now, I´m running this code to retrieve the values of the data:
`
var database = firebase.database();
database.ref().once('value', function(snapshot){
if(snapshot.exists()){
var content = '';
snapshot.forEach(function(data){
var val = data.val();
content +='<tr>';
content += '<td>' + val.nombre + '</td>';
content += '<td>' + val.lugar + '</td>';
content += '<td>' + val.ubicacion + '</td>';
content += '<td>' + val.propina + '</td>';
content += '</tr>';
});
$('#ex-table').append(content);
}
});`
But the " propina"
value is not displayed, giving me just \[object Object\]
in the HTML.
The issue is that propina
is an object , not a string or a number . You need to access its value . You can access the value like this:
...
content += '<td>' + val.propina.value + '</td>';
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.