I'm developing an app that scans qr codes. I have a service dedicated to the scanner device where I get the data scanned.
this.dataWedge.scanResult$
.pipe(
tap(_ => (this.scanning = false)),
filter(_ => this.assignState.getAssign() === this.assignState.Default),
switchMap(scanData =>
this.api.callApi(
PurchaseOrderQuery,
{
DataString: scanData.DataString
}
)
)
)
.subscribe(purchaseOrder => {
this.scannedResult$.next(purchaseOrder);
});
The problem is that when I pass a datastring that doesn't exist in the database, the api call fails (as it should be), but it never goes in the subscribe. How can I catch the error response from the api when this fails? Is it because of the switchMap maybe?
catchErrorafterswitchMap.