I am trying filtering the return of HTTP request in Angular 7 using RXJS6.
I must filter the response; only get the Users with IdSkill equals to 1234.
However, I cannot achieve this. I just received this error:
Type 'Observable' is not assignable to type 'Observable>'. Type 'User[]' is missing the following properties from type 'Pagination': total, items
RXJS is not my strong skill; I just use the basics, only to do simple get/post HTTP requests.
My code:
/* Interface */
export interface Pagination<t> {
total: number;
items: t[];
}
export interface User {
idUser: number;
name: string;
active: boolean;
skill: Skill;
}
export interface Skill {
idSkill: number;
name: string;
}
/* Service */
getUsers(): Observable<Pagination<User>> {
return this._httpClient.get<Pagination<User>>(
'http://localhost/api/users',
{ headers: this._auth }
).pipe(
filter(x => x.items.filter(user => user.skill.idSkill == 1234))
);
}
Thank you