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

4th Apr 2021, 2:07 AM
Tushar Jain
Tushar Jain - avatar
2 ответов
+ 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); }
5th Apr 2021, 7:26 AM
Mohammed Alotaibi
0
Thanks
7th Apr 2021, 2:14 AM
Tushar Jain
Tushar Jain - avatar