im trying to get the data of a single document and save it to a variable for use it later in another logic operation. The firestore documentation show hot to do this only with promises but i can't set the doc.data() value to a variable for later use, only inside the then() or catch() method. I can set a variable there but i can't use it outside the promise.
Firestore documentation example:
var docRef = db.collection("cities").doc("SF");
docRef.get().then(function(doc) {
if (doc.exists) {
console.log("Document data:", doc.data());
} else {
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
});