Asynchronous Firebase query to response
问题 I'm trying to get all documents from a firebase collection, create a list and return it on request with a Cloud Function, but I'm struggling with the asynchronous nature of JavaScript. Here's my code so far: firebase.initializeApp(firebaseConfig); const db = firebase.firestore(); const items = ""; async function buildItems() { db.collection("reminders").get().then((QuerySnapshot) => { QuerySnapshot.forEach((item) => { items.concat("<li>" + item.data().name + "</li>"); console.log(items); });