I am facing some problem when use angular 2 to query data from Firestore.
Could anyone please help me by checking it and tell me where I have done wrong ?
My error:
ERROR Error: The query requires an index. You can create it here: https://console.firebase.google.com/project/admin-e8a7b/database/firestore/indexes?create_index=EgR0ZW1wGgcKA3VpZBACGg0KCXN0YXJ0ZWRBdBADGgwKCF9fbmFtZV9fEAM at new FirestoreError (vendor.bundle.js:19925)
This is my code:
getTemp(uid): Observable<any> {
let temps = [];
var today = new Date();
return this.afs.collection<Temps>('temp', ref => ref.where('uid', '==', uid).orderBy('startedAt', 'desc')).snapshotChanges()
.map(actions => {
return actions.map(action => {
const data = action.payload.doc.data() as Temps;
console.log(data.temp);
return data.temp;
});
});
}