Error in Searching from Firebase realtime database


#1

I am trying to build a app which shows a list from the firebase database. Since the list is so big , therefore I was trying to apply a searchbar and search according to the titles. But I am getting a error that “movie.title” is undefined.
this is the code i am using

filterItems(searchTerm){
this.loadAndParseMovies();
return this.movies.filter((movie) => {
console.log(movie);
return movie.title.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1;
});
}

where loadAndParseMovies is fetching data from firebase database.

loadAndParseMovies(){
this.movies = this._DB.renderMovies();
}

renderMovies() : Observable
{
try {
return new Observable(observer =>
{
let films : any = [];
firebase.database().ref(‘films/’).orderByKey().once(‘value’, (items : any) =>
{
items.forEach((item) =>
{
films.push(item.val());
});

           observer.next(films);
           observer.complete();
        },
        (error) =>
        {
          console.log("Observer error: ", error);
          console.dir(error);
          observer.error(error)
        });
     });
  }
  catch(error)
  {
     console.log('Observable for retrieving films fails');
     console.dir(error);
  }

}

Can anyone pls help me with this …