即使我已经设置了允许读取这样的数据的规则,我仍然收到此错误:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow get, create, update, delete: if true;
}
}
这是我获取数据的方式:
getAllByConstraint(p_field, p_constraint) {
return new Promise( async (resolve, reject) => {
try {
const db = getFirestore()
const request = query(collection(db, 'report'),
where(p_field, '==', p_constraint))
const snapshot = await getDocs(request)
console.log("constraint" + p_constraint)
if (!snapshot.empty) {
const results = snapshot.docs.map(doc => doc.data());
resolve(results);
} else {
throw new Error(`Fetching failed. No information found.`)
}
}
catch(error) { reject(error) }
})
}```
更新您的 Firebase 规则
rules_version = '2';
服务cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, create, update, delete: if true;
}
}