Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Don't cancel the first observable if the second fails, how to keep it (forkJoin, zip). Angular 11

I have parallel API calls. How to continue getting data from one of them if second one failed?

forkJoin([a,b])
      .subscribe({
        next: ((data) => {
          const [first, second] = data;
        })

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It seems to me that combineLatest is what you are looking for, with a catchError to each of your observables to manage errors. Something like:

combineLatest([
  obs1$.pipe(catchError(() => of(null)),
  obs2$.pipe(catchError(() => of(null)),
]).subscribe(([first, second]) => { console.log(first,second); });
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading