Let us assume that I want to fetch data in my Angular application by calling a REST API in order to display it in the Angular application.
I would call something like this:
this.http.get(this.configUrl).subscribe(response => {
//do something
});
However, I often have the case that I have to fetch further data based on the first REST API call.So I have something that looks like this:
this.http.get(this.configUrl).subscribe(response => {
//next call
this.http.get(this.configUrl).subscribe(response => {
//next call
this.http.get(this.configUrl).subscribe(response => {
//next call
this.http.get(this.configUrl).subscribe(response => {
//do something
});
});
});
});
I find this very difficult to read. Is there a way to make this more readable in Angular / Typescript or am I doing something fundamentally wrong?