constructor(private http: HttpClient) {
this.data = this.http.get<{ [key: string]: object; }[]>('https://swapi.co/api/people/').pipe(
map((args: any) => {
return args.results;
})
);
} |
public filterArgs: any;
constructor(private http: HttpClient) {
let _this = this;
const api: string = 'https://swapi.co/api/people/?search='
this.filterData = this.searchTerm$
.pipe(
debounceTime(300),
distinctUntilChanged(),
switchMap((s: string) => this.http.get(`${api}${s}`)),
map(r => r.results)
);
this.filterData.subscribe(r => {
_this.filterArgs.updateData(r);
_this.autoObj.hideSpinner();
console.log(r)
});
}
onFiltering(args: FilteringEventArgs): void {
args.preventDefaultAction = true;
this.filterArgs = args;
this.autoObj.showSpinner();
this.searchTerm$.next(args.text);
} |