I'm trying to display the snapshot data from the database to the html page, but it seems to display an '[object Object]'instead of the gmail. I'm new to code so please be patient. here is the code:
firebase.database().ref('gmails/').get().then((snapshot) => {
if (snapshot.exists()) {
console.log(snapshot.val());
var content = '';
// give each message a unique ID
content += "<li>";
content += snapshot.val();
content += "</li>";
document.getElementById("gmails").innerHTML += content;
} else {
console.log("No data available");
}
}).catch((error) => {
console.error(error);
});
THE HTML:
<ul id="gmails">
</ul>
In the image you can see the object instead of the value