I know there have been several questions regarding this, but I havent found a way that works for me properly. If you find one gladly send it to me.
So I am getting my data from an API and I convert this data into an array of my required datatype:
getData(): Observable<Type[]> {
return this.http.get<Type[]>("URL)
.pipe(
retry(2),
catchError(this.handleError)
);
}
I want to use the data, after I got it.
Some ways i tried to solve this were with while(empty){...} which seems to be unefficient and not correct if the array is empty, Promises where I didn't really find a way to connect properly with observables and await/async which seems to be impossible with observables.
My code of implementing this:
array: Type[] = [];
useJSON(searchString: string) {
this.configService.getData().subscribe(results => { this.array = results});
// --operations--
}