forkJoin
when only one of the calls fails.forkJoin
to make two server callsforkJoin
operation that will hold an array of User
and an array of Post
forkJoin
will generate an error notification.
Then the observer’s error
notification will be invoked and we won’t see any result on the screen:catchError
catchError
to handle forkJoin
errors may be a good solution.
Although it might work under some circumstances, it is not the solution I would use in this case.catchError
will intercept the error but the only thing we can do is create a new observable that emits a default value: for example an object with the same structure emitted by forkJoin
but with empty arrays.
This is what we do in the next script: