From 6f7a63bb359ff8a8513136e7396d1e47c48916ea Mon Sep 17 00:00:00 2001 From: Hung Pham Date: Fri, 1 May 2026 20:10:16 +0700 Subject: [PATCH] feat(challenge 38): add error handling to HTTP request using catchError --- apps/rxjs/38-catch-error/src/app/app.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/rxjs/38-catch-error/src/app/app.component.ts b/apps/rxjs/38-catch-error/src/app/app.component.ts index 65e177567..9220eef55 100644 --- a/apps/rxjs/38-catch-error/src/app/app.component.ts +++ b/apps/rxjs/38-catch-error/src/app/app.component.ts @@ -3,7 +3,7 @@ import { HttpClient } from '@angular/common/http'; import { Component, DestroyRef, OnInit, inject } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormsModule } from '@angular/forms'; -import { Subject, concatMap, map } from 'rxjs'; +import { Subject, catchError, concatMap, map, of } from 'rxjs'; @Component({ imports: [CommonModule, FormsModule], @@ -41,7 +41,9 @@ export class AppComponent implements OnInit { .pipe( map(() => this.input), concatMap((value) => - this.http.get(`https://jsonplaceholder.typicode.com/${value}/1`), + this.http + .get(`https://jsonplaceholder.typicode.com/${value}/1`) + .pipe(catchError((error) => of(error))), ), takeUntilDestroyed(this.destroyRef), )