0

enter image description here

I tried to use Firebase Translate Text Extension to translate a text in my chat app project with Javascript. To do that, I have to add the target text into “document” at the Cloud Firestore (Add data to Cloud Firestore), but had the error:

"Uncaught (in promise) FirebaseError: Missing or insufficient permissions."

const docRef = await db.collection('translations').add({
    input: document.getElementsByTagName("body")[0].innerHTML,
    created: firebase.firestore.Timestamp.now()
});
console.log(docRef);

✔︎ Firebase rules are default.
✔︎ Firebase Deploy completed successfully
✔︎ Firebase Realtime Database works correctly
× Can't add document to Firestore Database data

I just followed this GitHub sample code.
Please someone help me out.
Thank you very much in your advance.

Firestore Rules

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if false; //changed to "true" and it works
   }
  }
}
Jay U.
  • 23
  • 4
  • It looks like the user running this code does not have permission to write to the database. I recommend checking out some of the existing [questions about this error message](https://www.google.com/search?q=site:stackoverflow.com+Uncaught+(in+promise)+FirebaseError%3A+Missing+or+insufficient+permissions) to learn how to fix that. – Frank van Puffelen May 07 '21 at 14:48
  • Can you post the rules that you say are 'default' - are they closed or open? – DIGI Byte May 08 '21 at 00:11
  • @DIGIByte I changed "write: if true;" and it works. Thank you for your suggestion! – Jay U. May 08 '21 at 02:00

0 Answers0