I'm trying to connect my react js application with Firebase Firestore but I'm getting the below error as shown in the image error image I'm having 2 documents in the collection but I'm getting an empty array as you can see in the console. This is the code I'm using to fetch firestore data
const snapshot = await firebase.firestore().collection('users').get();
const data = snapshot.docs.map((doc) => doc.data());
console.log(data);
PS: I'm able to use auth function from firebase properly but getting an error with firestore.
Solutions I have tried so far:
- Sync the clock
- verified the firebase rules and made sure read and write are allowed (attaching the rules I found in firestore rules section)
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if
request.time < timestamp.date(2021, 6, 23);
}
}
}
Looking for some quick solutions as I'm struggling since last night. Thanks in Advance.