Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
102
rated 0 times [  108] [ 6]  / answers: 1 / hits: 23756  / 7 Years ago, tue, january 9, 2018, 12:00:00

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).


More From » firebase

 Answers
217

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.


[#55504] Saturday, January 6, 2018, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kinsley

Total Points: 352
Total Questions: 84
Total Answers: 94

Location: Denmark
Member since Tue, Jul 19, 2022
2 Years ago
;