I have been working on implementing server-side search in Angular 7. I managed to find some code for implementation, but unfortunately it is not functioning as expected. The issue I am encountering is that when searching for a string, the code sends multiple HTTP requests instead of just one. Below is the section of my code where this problem occurs.
fromEvent(this.simpleSearchInput.nativeElement, 'keyup').pipe(
debounceTime(500),
switchMap((search: any) => {
return this.usersService.simpleUserSearch(search.target.value);
})
).subscribe(res => {
this.queryUsers = res.result.data;
console.log('User Name is :' + res);
});
}