trying to read in the following branch
"finance": {
"lvAN928K9qXJ5RGiRBUrb6seByM2": {
"-N6XXgy0COp30w52pxzZ": {
"link": "https://firebasestorage.googleapis.com/v0/b/myhouse-4ba96.appspot.com"
},
"-N6XXh2rkW0jT7MNpO2-": {
"link": "https://firebasestorage.googleapis.com/v0/b/myhouse-4ba96.appspot.com"
},
"email": "app@email.com",
"houseContractor": "General construction ",
"houseCost": "2400000",
"income": "1200000",
"institution": "Commercial Banks",
"nic": "123456789",
"permit": "Yes"
I need to access from email to permit as well as the 2 link under the 2 keys. My code reads the data but the output is incorrect. All data goes in a table row.
Code i tried
try
{
const dbref = ref(db);
get(child(dbref,"finance")).then((snapshot)=>
{
var client=[];
snapshot.forEach(childSnapshot =>{
childSnapshot.forEach((grandchildSnapshot) =>{
if(grandchildSnapshot.hasChild("link"))
{
let item2=childSnapshot.val();
let item=grandchildSnapshot.child("link").val()
client.push(item);
client.push(item2)
}
});
});
AddAllItemsToTable(client);
function AddAllItemsToTable(quotation) {
tbody.innerHTML = "";
quotation.forEach(element => {
addItem(element.nic,element.email,element.permit, element.institution, element.income, element.houseContractor, element.houseCost,element.link,element.link);
});
The output is produces