I'm trying to display data from Firebase Database into an html document. Under you can see both my HTML and JavaScript file. I'm pretty new to Firebase, so I have most likely done a mistake. Appreciating all answers!
Thanks in advance!
HTML:
<p id="profile"></p>
<table id="profiledetails-table">
<tr id="tr">
<th>Name</th>
<th>Email</th>
</tr>
</table>
Javascript:
firebase.auth().onAuthStateChanged(function(user) {
var docRef = db.collection('users').doc(firebase.auth().currentUser.uid)
docRef.get().then(function(snapshot) {
if (doc.exists) {
console.log("Document data:", doc.data());
$('#profiledetails-table').append(doc.data);
} else {
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
})
});