i want to wait for the getAnswers value response from firebase and push it in the foreach array ! how can i do that ?
async fetchData() {
console.log('fetchdata')
const UID = Firebase.auth().currentUser.uid;
const ref = FirebaseRef.child('my_questions/' + UID + '/');
// console.log(ref);
ref
.orderByKey()
.limitToLast(this.state.limit)
.once('value', snapshot => {
var items = [];
snapshot.forEach(child => {
var getAnswers = await FirebaseRef.child('counter/questions/' + child.key + '/count_answers').once('value')
items.push({
key: child.key,
...child.val(),
count_answers: getAnswers
});
});
})
}