Currently working on implementing Typeahead search functionality using API data. When we input valid data, the autosuggestions work correctly. However, if we input invalid data, we receive an error message. The issue arises when trying to input valid data again, as the API does not trigger. In order to address this, I have attempted the following code. Any guidance on how to handle error scenarios for invalid data would be greatly appreciated.
asyncData: string;
dataSource: Observable<any>;
this.dataSource = new Observable((observer) => {
observer.next(this.asyncData)
}).mergeMap(() => {
return this.http.get('/api/testAPI',{params: {param1: param1}});
});