import { Injectable } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';
import { map } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class FirestoreDbService {
constructor(private db: AngularFirestore) { }
getBuildList() {
// return this.db.collection('Builds').valueChanges();
return this.db.collection('Builds').snapshotChanges().pipe(
map(docArray => {
return docArray.map(doc => {
console.log('==', doc.payload.doc.id);
console.log('$==$', doc.payload.doc.data());
return{
id: doc.payload.doc.id,
... doc.payload.doc.data()
}
})
})
)
}
}
On the last line I am getting the error. I think this is something to do with typescript. Any help appreciated
Use the as keyword:
... doc.payload.doc.data() as {}
This will tell the compiler to treat doc.payload.doc.data() as an object.