Reputation: 47
I need to get the userKey (auto-generated) for my future request:
addItemToCollection(userMail,item){
let userKey;
firebase.database().ref('user-list').orderByChild('email').equalTo(userMail)
.once('value')
.then(snapshot => {
snapshot.forEach(function(child) {
//userkey is the value that i want
userKey= child.key
});
});
//Outside the promise i need userkey Value.
this.collectionRef=this.db.list('user-list/'+userKey+'/collection/bouteille');
return this.collectionRef.push(item);
}
this.db can't be find in my promise that why im there today (im new to ionic 3 and firebase)
Upvotes: 1
Views: 1723