Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- doc.data() // For Each doc
- Array[] // Filled with data and length 54
- Length: 54
- Array[] // Filled with data and length 54
- Length: 0
- doc.data() // For Each doc
- let exportArray = [];
- let promises = [];
- db.collection('lists').doc('List 1').collection("members")
- .get().then(function(querySnapshot) {
- querySnapshot.forEach(function(doc) {
- promises.push(
- new Promise(function (resolve, reject) {
- exportArray.push(doc.data());
- resolve();
- console.log('before');
- })
- );
- });
- });
- Promise.all(promises).then(function () {
- console.log(exportArray); // Logs correctly with all data with length 54
- console.log(exportArray.length); // Logs as 0 for some reason
- });
Add Comment
Please, Sign In to add comment