I am attempting to get data from a firebase database but it is saying I do not have permission, even though the rules are totally open.
I started building this current implementation by following this youtube tutorial. After running into errors with the deprecated FirebaseListObservable, I changed my provider according to this update information. I also tried using the default open Firebase rules as well as the ones they recommend for "Allow All" in the Firebase documentation.
The default open version of the rules, which also didn't work, had the line as allow read, write;
In the same way as can be seen 1 minute into the mentioned youtube tutorial, I am calling initializeApp(firebaseConfig)
in the imports of my app.module.ts using the information from clicking "Add Firebase to your web app"
I am using angularfire2@5.0.0-rc.8.0
which I installed with npm install angularfire2
. When I ran npm list
just now it gave me the following two warnings, which may be relevant to the issue. I'm using @angular/common@5.2.10
and @angular/core@5.2.10
npm ERR! peer dep missing: @angular/common@^6.0.0, required by angularfire2@5.0.0-rc.8.0 npm ERR! peer dep missing: @angular/core@^6.0.0, required by angularfire2@5.0.0-rc.8.0
The issue was that within the Firebase dashboard I was configuring the Cloud Firestore (BETA)
database as opposed to the Realtime Database
database. After switching to using the proper database and setting the rules I was able to get the data from both Storage and Realtime Database using the basic firebase library (didn't need angularfire2).
In this example I get a snapshot of the root node and then, based off the key of that node, iterate through snapshots of each child node and store the .val()
into the associated array. (note: the layout of the data in the new database is different from the format in the screenshot from the question)
import * as firebase from 'firebase';
...
guardiansList: any = [];
warriorsList: any = [];
prayersList: any = [];
...
try {
firebase.database().ref().once('value', (snapshot) => {
snapshot.forEach((categorySnap) => {
switch (categorySnap.key) {
case "guardians":
categorySnap.forEach((imgSnap) => {
this.guardiansList.push(imgSnap.val());
return false;
});
break;
case "warriors":
categorySnap.forEach((imgSnap) => {
this.warriorsList.push(imgSnap.val());
return false;
});
break;
case "prayers":
categorySnap.forEach((imgSnap) => {
this.prayersList.push(imgSnap.val());
return false;
});
break;
default:
console.log("Found Unknown Key");
break;
}
return false;
});
});
}
catch (e) {
console.log(e);
}