I have a database with users who need to complete unique homework sessions. Each homework session has its own identifier, name, date, and other details.
After fetching all the user's homework from the database, it is stored in a private variable called
userHomework: Observable<any>
. I want to be able to search for a specific homework by name that the user inputs.
To achieve this, I am using the following function:
this.userHomework = this.userHomework.map(allHomework =>
allHomework.filter(homeworkSession =>
homeworkSession.name.toLowerCase().includes(this.userInput.toLowerCase())));
Unfortunately, when I run this function, I encounter the error message:
allHomework.filter is not a function
.
I have attempted importing the filter method in two different ways:
import 'rxjs/add/operator/filter';
and
import { filter } from 'rxjs/operators';
However, with the second import, I also receive the warning:
[ts] 'filter' is declared but its value is never read.
Can someone please help me identify where I went wrong and how I can effectively filter my Observable?