I'm trying to firestore documents through react native app, but facing the following issue
Here is the code
constructor() {
super();
this.ref = firebase.firestore().collection('todos');
}
and we are triggering button click
addTodo() {
this.ref.add({
title: this.state.textInput,
complete: false,
});
}
we are facing this issue
Error: Firestore: The caller does not have permission to execute the specified operation. (firestore/permission-denied). Error: Firestore: The caller does not have permission to execute the specified operation. (firestore/permission-denied).
Select the default Firestore location and click to enable your database. Continue configuring your Firebase by adding the Firebase web SDK to our React app. To do this, click on the web icon on your project overview screen. Your next prompt will require you to add Firebase to your web app.
If this error occurs when you run addTodo()
it means that the user doesn't have permission to write to the todos
collection. Access to Firestore data is controlled through its server-side security rules.
To simply allow anyone to write to todos
use a rule such as this:
service cloud.firestore {
match /databases/{database}/documents {
match /todos/{document=**} {
allow read, write: if true;
}
}
}
But I highly recommend you read the documentation so that you can write more secure rules that match the needs of your app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With