This is my database structure below tutorCopy is the currentId of the user on basis of which I have to retrieve the user email but the problem is I can't get it, I have tried two methods but both are not working: 1st method with promise
componentWillMount(){
let user = firebase.auth().currentUser.uid;
const emailFetch = ["useremail"]
const emailpromise = emailFetch.map(id => {
return firebase.database().ref("tutorCopy/").child(user).child(id).on('value', s => s)
})
Promise.all(emailpromise)
.then(user => {
this.setState({ markers: s.values(s.val()) })
})
.catch(err => {
console.log(err)
})
}
Other one with snapshot:
componentWillMount(){
var user = firebase.auth().currentUser.uid;
var currId = JSON.stringify(user);
firebase.database().ref("tutorCopy/").child('user').once("value", snapshot => {
this.setState({ markers: Object.values(snapshot.val()) })
})
}