I have a an array of a number of N paths to retrieve data from a different location in firebase database.
searchPaths = ['locations/date1/imageID', 'locations/date2/imageID2', locations/date3/imageID3, ...]
now, I want to loop through each search path and pull a value from it to save an array of image URL's.
const searchPaths = ['locations/date1/imageID', 'locations/date2/imageID2']
const imageURLs = []
for(var Obj in searchPaths)
{
const path = Obj
admin.database().ref(path).once('value').then(snapshot =>
{
const URL = snapshot.val().fileURL;
imageURLs.push(URL);
console.log('ImageURL: ' + URL );
})
// here is where it gets sour
}.then(() => {
console.log("All image URL's" + imageURLs")
}
So, my question is, how do I return a promise when we have now pulled the data we need from every ref? is there a Promise.all type? where does it go?