Play with the code here => https://stackblitz.com/edit/playground-rxjs-f8xjsh
Hi, I'm trying to simulate a failed API Call that will emit the error value at the subscribe() { Error: } part.
import { from, of, pipe, forkJoin, interval, AsyncSubject, BehaviorSubject,defer, Subject, timer, observable, throwError } from 'rxjs';
import { concatMap, map, mergeMap, zipWith, delay, tap, concatAll, concat, concatWith, switchMap, catchError } from 'rxjs/operators';
const apiCall = (callNumber, isError=false) => of('Api Call Result ' + callNumber).pipe(
tap(_=>console.log('Calling Api ' + callNumber)),
delay(1000),
tap(_=> throwError(() => new Error('ERROR')))
);
apiCall(99,true).subscribe({
next: x=>console.log(x),
error: e=>console.log(e)
});
Currently the error is not caught i.e. logged. Can someone help?
Stackblitz => https://stackblitz.com/edit/playground-rxjs-f8xjsh