I'm having trouble trying to add a image to my realtime database and thus have it display on the site. In the code shown below it appears in the firebase storage but it does not appear in the database. How can I make it do both?
var newData = {
UUID: refUUID,
Status: 'Active',
Recommended: false,
Price: priceValue.replaceAll(',', ''),
Location: {
Address: addressValue,
City: cityValue,
State: stateValue,
Zip_Code: zipCodeValue,
Country: 'US'
},
Description: {
Date_Listed: date + ' ' + time,
Bathrooms: bathroomsValue,
Bedrooms: bedroomsValue,
Description: descriptionValue
}
}
ref.set(newData);
for (let i = 0; i < filess.length; i++) {
storage.ref(refUUID + '/' + filess[i].name).put(filess[i]).then(() => {
storage.ref(refUUID + '/' + filess[i].name).getDownloadURL().then(function (url) {
database.ref(listingType + '/' + refUUID + '/Description/Images/Image' + (i + 1)).set({
Link: url,
name: 'Image' + (i + 1)
})
});
});
}
clearFields();
addAuditLog('Added Listing', refUUID, '');
document.getElementById('add-successful-modal').style.display = 'block';