I'm using Firebase authentication service.
I'm using some basics rules which WORK when I'm using the app
I have a service which fetch data from Firebase :
export class WorkoutService { myWorkoutList: any[] = []; constructor(private firestore: AngularFirestore) {} fetchWorkouts() { this.firestore .collection('performances) .doc(emailAddress) .collection('myDocumentCollection') .valueChanges() .subscribe( (allWorkoutElements) => { this.myWorkoutList = allWorkoutElements; // some HEAVY logic (: ... }); } }
The problem is : Whenever I reload my page, I have an error message:
Error: Missing or insufficient permissions.
The work-around I found is to add a delay to my service call :
setTimeout( () => this.fetchWorkouts(), 500);
It looks like Firebase auth is taking time to "set up" after a refresh, so my request to Firebase is denied. How can I wait for Firebase auth to complete before I do my fetch?