I have problems going further with my Promise that is returned from the getPostedPlaces()
. When I run getAll()
it prints out the Array seen below. The array seems correct, but how do I get the getAll()
function to return an actual array. I can only print it, but I can't return the array itself. I have also tried to push the object inside the array onto an array, but the it returns empty. Frustrating.
const getPostedPlaces = async () => {
const querySnapshot = await getDocs(collection(db, "posted_places"));
const newSnapshot = querySnapshot.docs.map(doc => {
let newDoc = doc.data();
newDoc.id = doc.id;
return newDoc;
});
return newSnapshot;
}
const getAll = () => {
getPostedPlaces().then(res => console.log(res))
}
The array:
Array [
Object {
"active": true,
"category": Array [
"tøj",
"møbler",
],
"email": "bar@gmail.com",
"house_nr": 1,
"id": "i3juWf6Rj4OPBoKAjkBD",
"location": Object {
"latitude": 55.69718057,
"longitude": 12.52470763,
},
"price_interval": Array [
100,
700,
],
"street_name": "Hvidkildevej",
"time_end_actual": "",
"time_end_expected": "Sat Feb 05 2022 18:00:00 GMT+0100 (CET)",
"time_start": "Sat Feb 05 2022 09:00:00 GMT+0100 (CET)",
"zip_code": 2400,
},
]