Below are my security rules for firestore database:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
Below is my code to fetch data:
fetchUsers=async()=>{
const db=firebase.firestore();
const response=db.collection('users');
const data=await response.get();
data.doc.forEach(item=>{console.log(item)})
}
users is the name of the collection in the firestore. It has one document.
But I get an error on console:
Cannot read forEach property of undefined
what am I missing? Please help me to find the solution of above problem.
Thank You!