You encounter the "permission_denied" error while attempting to send data to Firebase. This error arises because the Firebase database is initially accessible only to administrative users. To rectify this, you have two options:
{ "rules": { ".read": true, ".write": true } }
Caution: Remember to re-secure the database before going into production to prevent abuse.
firebase.auth().signInAnonymously().catch(function(error) { // Handle Errors here. });
firebase.auth().onAuthStateChanged(function(user) { if (user) { // Signed in. var userRef = app.dataInfo.child(app.users); var useridRef = userRef.child(app.userid); useridRef.set({ locations: "", theme: "", colorScheme: "", food: "" }); } });
By following these steps, you can resolve the permission denied error and send data to the Firebase database successfully.
The above is the detailed content of Why Am I Getting a \'permission_denied\' Error When Sending Data to Firebase?. For more information, please follow other related articles on the PHP Chinese website!