-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Version info
Angular: 16.2.0
Firebase: 10.3.1
AngularFire: 7.6.1
Other (e.g. Ionic/Cordova, Node, browser, operating system):
Google Chrome
Windows 11
Node v18.16.1
How to reproduce these conditions
I am getting error when trying to read firestore collection. I
I have implemented the code with AngularFire Cloud Firestore document. https://github.com/angular/angularfire/blob/master/docs/firestore.md#cloud-firestore
Failing test unit, Stackblitz demonstrating the problem
Steps to set up and reproduce
app.module.ts
imports: [
provideFirebaseApp(() => initializeApp(environment.firebase)),
provideAnalytics(() => getAnalytics()),
provideAuth(() => getAuth()),
provideDatabase(() => getDatabase()),
provideFirestore(() => getFirestore()),
provideFunctions(() => getFunctions()),
provideMessaging(() => getMessaging()),
providePerformance(() => getPerformance()),
provideRemoteConfig(() => getRemoteConfig()),
provideStorage(() => getStorage())
]
auth.service.ts
import { Inject, Injectable, inject } from '@angular/core';
import { Observable } from 'rxjs';
import { Auth, authState, signInWithEmailAndPassword,
createUserWithEmailAndPassword, onAuthStateChanged,
signOut, GoogleAuthProvider,
user} from "@angular/fire/auth";
import { Firestore, collectionData, collection, getFirestore, getDocs } from "@angular/fire/firestore";
import { AngularFireAuth, } from '@angular/fire/compat/auth';
import { Router } from '@angular/router';
@Injectable({ providedIn: 'root' })
export class AuthService {
userData: any;
UsersCollection: any;
UsersData: any;
constructor(
private auth: Auth,
private firestore: Firestore,
private afAuth: AngularFireAuth,
private router: Router
) {
console.log(this.firestore);
const itemCollection = collection(this.firestore, 'Classes');
}
}
Sample data and security rules
Debug output
** Errors in the JavaScript console **
ERROR FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore main.ts:13 FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore
** Output from firebase.database().enableLogging(true);
**