Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Get and return firestore collections in react native

$
0
0

I just started learning to react native and firebase, so I want to get all collections from firestore, but the problem is when I want to return data they give me undefined even when I use async/await

async getAllAssistances() {            let allAssistances;            const  assistances = await firebase.firestore().collection('assistances')            assistances.get().then((querySnapshot :any) => {                const tempDoc = querySnapshot.docs.map((doc:any) => {                  return { id: doc.id, ...doc.data() }                })               console.log('====================================');               console.log(tempDoc);               console.log('====================================');                allAssistances = tempDoc;              })            console.log('********************************');            console.log(allAssistances);            console.log('********************************');            return allAssistances;    }// Output : ====================================Array [  Object {"city": "test","description": "test","id": "0N0iYx8RCPPSIEXfUQUk","latitude": 1,"longitude": 1,"nbPlaces": 1,  },]====================================********************************undefined********************************

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>