I'm still learning web development and have researched promises and I feel I have a basic understanding of it but am still failing to return a result. I'm sure this is something already answered somewhere in the confusing world of Stackoverflow but I have not found anything useful.
Stackoverflow link: for those who like linking to other articles
I tried the then function in that article in various ways and still am only receiving a promise result.
The function below is where I am hoping to receive a result. I am calling the datePresent function which returns a promise. After the promise is returned it should return a boolean
function resultBoolean(){
return
datePresent().then(function(result){
return result;
});
}
datePresent Function
function datePresent(){
var date = "07-10-2018";
var id = "SWSyWAJlkVDqSIzrcHdm";
var documentReference =
db.collection("clients").doc(id).collection("sessions").doc(date);
return documentReference.get().then(function(documentSnapshot) {
if (documentSnapshot.exists) {
return true;
} else {
return false;
}
});
}
Maybe I am not comprehending promises.
Aucun commentaire:
Enregistrer un commentaire