Bird
0
0

Which RxJS import is required to use catchError in Angular?

easy🧠 Conceptual Q2 of 15
Angular - RxJS Operators
Which RxJS import is required to use catchError in Angular?
Aimport { catchError } from '@angular/core';
Bimport { catchError } from 'rxjs';
Cimport { catchError } from 'rxjs/operators';
Dimport { catchError } from 'rxjs/internal';
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct import path

    The catchError operator is part of RxJS operators and must be imported from 'rxjs/operators'.
  2. Step 2: Eliminate incorrect imports

    It is not directly from 'rxjs' or Angular core, and internal paths are not for public use.
  3. Final Answer:

    import { catchError } from 'rxjs/operators'; -> Option C
  4. Quick Check:

    catchError import = 'rxjs/operators' [OK]
Quick Trick: Always import catchError from 'rxjs/operators' [OK]
Common Mistakes:
MISTAKES
  • Importing catchError directly from 'rxjs'
  • Trying to import from '@angular/core'
  • Using internal RxJS paths

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes