Reputation: 5068
I have a Firebase collection like this:
I am trying to get the data that has the date range condition using this code:
ticket-form.component.ts
onSubmmitDates(value: any) {
debugger;
this.ts.getSpecificTicket(value.dateFrom, value.dateTo).subscribe((data: any) =>{
console.log(data);
});
}
ticket.service.ts
private ticketList: AngularFireList<any>;
constructor(
private firestore: AngularFirestore,
private afDatabase: AngularFireDatabase,
) { }
getSpecificTicket(dateFrom: Date, dateTo: Date): any {
this.ticketList = this.afDatabase.list('tickets', ref =>
ref.orderByChild('issuedOn').startAt(dateFrom.toString()).endAt(dateTo.toString()));
return this.ticketList.snapshotChanges();
}
When I run it, I get this error:
ERROR Error: permission_denied at /tickets: Client doesn't have permission to access the desired data. at errorForServerCode (index.cjs.js:642) at onComplete (index.cjs.js:8944) at Object.onComplete (index.cjs.js:12467) at index.cjs.js:11611 at PersistentConnection.push../node_modules/@firebase/database/dist/index.cjs.js.PersistentConnection.onDataMessage_ (index.cjs.js:11853) at Connection.push../node_modules/@firebase/database/dist/index.cjs.js.Connection.onDataMessage_ (index.cjs.js:11170) at Connection.push../node_modules/@firebase/database/dist/index.cjs.js.Connection.onPrimaryMessageReceived_ (index.cjs.js:11164) at WebSocketConnection.onMessage (index.cjs.js:11065) at WebSocketConnection.push../node_modules/@firebase/database/dist/index.cjs.js.WebSocketConnection.appendFrame_ (index.cjs.js:10657) at WebSocketConnection.push../node_modules/@firebase/database/dist/index.cjs.js.WebSocketConnection.handleIncomingFrame (index.cjs.js:10707)
This is my rules:
What can I do to resolve this?
Upvotes: 0
Views: 513
Reputation: 627
Check your permissions on your database Firebase. If you are on develope mode, you can just remove the permissions, but anyone will be able to access. For the time being when you are developing and you have not any problem with access permissions, You can simply do as shown below.
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
In the rules section.
Upvotes: 1
Reputation: 703
Make Sure You have given permissions to read/write as shown in the image.
Upvotes: 1