async onclick(){
let number=this.state.phoneNumber
if(number !== null && number.length===10){
console.log('number',number)
await firestore().collection('profile')
.where('mobile', '==', number).get().then(snapshot => {
if (snapshot.empty) {
}
else{
console.log(snapshot.data())
const res=Promise.resolve(async function(){
let data=[]
await snapshot.forEach(doc => {
data.push({data:doc.data().uid})
})
return data
})
if(res.length !==0){
res.then((pra)=>{
let payload={Requester:auth().currentUser.uid,Responder:pra}
firestore().collection('requests').add(payload).then(function() {
goHome();
});
})
}
}
})
}
else{
showSnackbar('Please enter valid mobile number');
}
}
this is the my code here here i want to wait for foreach to complete the after this is want to save the data received from the this foreach to firebase but issue is that before the foreach finish it is running the quert so i am getting null data in firebase