0
How to represent firebase data in website using JavaScript in tabluer format
How to represent firebase data in website using JavaScript in tabluer format
2 Respostas
+ 2
Hello. You can fetch data from Firebase using the following code:
(This data is from the Firestore database)
var mainDataBase = firebase.firestore().collection('main');
mainDataBase.get().then((querySnapshot) => {
querySnapshot.forEach((doc) => {
var first_name= doc.data().first_name;
var last_name= doc.data().last_name;
var age= doc.data().age;
addNewRow(first_name,last_name,age);
});
});
function addNewRow(first_name,last_name,age) {
let table = document.getElementById("myTable");
let tr = document.createElement("tr");
let td1 = document.createElement("td");
let td2 = document.createElement("td");
let td3 = document.createElement("td");
td1.textContent = first_name;
td2.textContent = last_name;
td3.textContent = age;
tr.append(td1,td2,td3);
table.append(tr);
}
0
Thanks