Is it possible to handle errors separately using forkjoin? I need to call multiple requests at the same time, displaying a loading on the screen while the requests are called. If an error occurs in some request, and another success, I need to display the request successfully on the screen, and the error message to the other.
Meu código no Page.ts:
getData(){
this.loadingService.showLoader("Loading, please wait");
Observable.forkJoin([
this.issuesService.getIssues(),
this.categoryService.getCaretories()
]).subscribe(
(response) => {
let issues = JSON.parse((response[0] as any)._body);
let categories = JSON.parse((response[1] as any)._body);
//do something with issues and categories
}, (error) => {
console.log(`Backend returned error was: ${error}`);
this.closeLoading(refresher);
this.showContent = false;
}, () => {
console.log('complete all request');
this.closeLoading(refresher);
});
}
}
If an error occurs in the Issues request, and in the Category request, return success. I need to display on the screen how to successfully categories, and display an error message for Issues.
Currently, when an error occurs, the error message is displayed for all requests.