Reputation: 712
For the past month or so I have been developing an app with Firebase's Real-time Database. It has been working great until today. For some reason, the database querying stopped working entirely. The authentication (email and password login, create an account, forgot password) all seem to work fine but for some reason, my app cannot retrieve the Firebase data.
I even went to previous builds of my app to test them out. They worked when tested and they also cannot connect to the database. Has anybody ever faced this problem before and if so how did you manage to fix it?
This is my code by the way but it was working moments ago so I doubt anything is wrong with it.
var firebaseResponse = firebase.database().ref().orderByChild("country").equalTo(country)
fireBaseResponse.once('value').then(snapshot => {
snapshot.forEach(item => {
const temp = item.val();
data1.push(temp);
});
Upvotes: 2
Views: 2104
Reputation: 1
Follow these steps... Realtime Database-->Rules--> just change read : true and write : true. Written below..
".read": true,
".write": true
It worked for me.
Upvotes: 0
Reputation: 18202
I faced a similar problem in one of my projects. It was loading data since yesterday but today it does not return anything.
I don't know how but this weird timestamp rule got added by default when I created the rule in my Firebase project.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.time < timestamp.date(2020,8, 22);
}
}
}
So I just removed the request.time < timestamp.date(2020,8, 22)
rule and replaced it with this.
allow read, write: if true;
allow read, write: if true; make your database public for read/write request. Add some security rules.
I was pretty sure that the problem was with my service.json file. So I checked everything but the rules because firebase does not add timestamp rule by default. Maybe I copied the rule from somewhere.
By luck and by logcat.
When I deep dived into logcat I found this warning message
[Firestore]: Listen for Query(deck_collection order by name) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
Upvotes: 0