import { Injectable } from '@angular/core';
import { AngularFireDatabase } from '@angular/fire/database';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class FirebaseService {
listings: Observable<any[]>;
constructor(private db: AngularFireDatabase) { }
getListings(){
this.listings = this.db.list('/listings') as Observable<Listing[]>
return this.listings;
}
}
interface Listing{
$key?:string;
title?:string;
type?:string;
image?:string;
city?:string;
owner?:string;
bedrooms?:string;
}
I'm trying to retrieve data as a list from Firebase using angularfirer2. But in this.listings = this.db.list('/listings') as Observable<Listing[]> I'm getting a error saying
Conversion of type 'AngularFireList<{}>' to type 'Observable' may be a mistake because neither type sufficiently overlaps with the other.
Can anyone help me with this matter.