skip to Main Content

Javascript – How to implement subscribe synchronously like async await. angular, firebase

the problem is that the console represent 'undefined'. this.firestore.collection('list').doc('1').get().subscribe((doc: any) => { this.myAns = doc.data().answer ? doc.data().answer : "no answer"; }); console.log('this.myAns', this.myAns); but, I want to get right answer in console. this.firestore.collection('list').doc('1').get().subscribe(async (doc: any) => { this.myAns = await…

VIEW QUESTION
Back To Top
Search