I have a promise and the console.log inside of the promise gives me a string, but I cant use the result outside of the promise as the result is undefined.
const docId = firebase
.firestore()
.collection('users')
.doc(user.uid)
.collection('payments')
.get()
.then(querySnapshot => {
querySnapshot.forEach(doc => {
console.log(doc.id);
return doc.id;
});
});
console.log(docId);
So console.log(doc.id) return a value, but I can't get the result and use it outside of the const docId. Is there a way to grab the result of doc.id and use it outside of the const docId?