I have this simple promise:
function getprofile(id) {
if(firebase.auth().currentUser){
firebase.database().ref('votes/' + id + '/' + firebase.auth().currentUser.uid)
.once('value')
.then(function(snapshot) {
if (snapshot.exists()){
console.log('ok1');
return '<span>user exists</span>';
}else{
console.log('ok2');
return '<span>user doesn\'t exist</span>';
}
});
}else{
console.log('ok3');
return '<span>you must be logged</span>';
}
}
But when I call it, instead of returning a span, the function returns "undefined" even though my console log works