0

This is my first try at getting angularjs to talk to firebase.

I have setup the firebase database in test mode so there is no auth but i keep getting an error

Controller code is

.controller('FaqsCtrl', ['$scope', '$firebaseArray', '$uibModal', function($scope, $firebaseArray, $modal, $filter) {               
    var ref = firebase.database().ref().child("faq");           
    $scope.faqs = $firebaseArray(ref);
}])

JS links as follow

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-route.min.js"></script>
<!-- Firebase -->
<script src="https://www.gstatic.com/firebasejs/5.5.4/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.5.4/firebase-database.js"></script>
<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/2.3.0/angularfire.min.js"></script>

Firebase rules are

service cloud.firestore {
  match /databases/{database}/documents {
   match /{document=**} {
    allow read, write;
   }
  }
}

Error is - Error: permission_denied at /faq: Client doesn't have permission to access the desired data.

Everything I have found on the web seems to be for an older version of Firebase

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
djcamo
  • 297
  • 2
  • 3
  • 14
  • The security rules you're showing apply to Cloud Firestore, while the code you're showing is accessing the Realtime Database. While both databases are part of Firebase, they're completely separate, and the security for one don't apply to the other. To fix the error, you will have to set the rules for the Realtime Database. For a walkthrough of how to do that, see https://stackoverflow.com/a/52129163 – Frank van Puffelen Oct 16 '18 at 13:47

1 Answers1

1

Go to Firebase console of your app Select Database From Side Menu --> Select Rule From tabs above --> Update your rule like this. { "rules": {
".read": true, ".write": true } }

hope it solve your problem.

saumil_
  • 304
  • 2
  • 11