I'm new to using async/await and am having some problems getting a function to work.
I have a function getRatings that maps through data returned from a call to my firebase firestore.
I'm wondering how I use async/await to return the data, because at the moment when I console.log the output of the function, I get
PromiseĀ {}
Here's the function in question, filteredVenue represents the data returned from the firebase call:
const getRatings = async () => {
let arr = [];
await filteredVenue.map((venue) => {
return venue.reviews.map((ratings) => {
const ratingsObject = {
food: ratings.ratingFood,
service: ratings.ratingService,
value: ratings.ratingValue,
atmosphere: ratings.ratingAtmosphere,
};
arr.push(ratingsObject);
})
})
const newObject = {
food: arr[0].food,
service: arr[0].service,
value: arr[0].value,
atmosphere: arr[0].atmosphere,
};
return newObject;
};
const venueRatings = getRatings()
console.log(venueRatings) // yields a pending promise
Any suggestions?