I have 4 functions similar to the one below. Right now I'm calling them one at a time on ngOnInit() but I'm looking for a cleaner way to call all 4 functions (GET HTTP Requests) so that they show spinner... all run parallel... and then close spinner and handle any errors. This is for a project using angular 7.
getCustomers() {
return this.apiService.getCustomers()
.subscribe(
(data: any) => {
this.partners = data;
this.loading = false;
},
error => {
console.log(error);
this.loading = false;
}
);
}
.subscribe()function, it doesn't stop the rest of the code execution. Are you trying to show a spinner when something does an HTTP call on your webapp?apiService.getCustomers()in this case). I've answered a similar question here stackoverflow.com/questions/46018259/…, 90% it still applies except for themap(), which you don't need to do if your classes match the response JSON structure. Angular has data casting support now.