Bird
0
0

Why is it important that Angular HTTP interceptors return an Observable instead of a Promise?

hard🧠 Conceptual Q10 of 15
Angular - HTTP Client
Why is it important that Angular HTTP interceptors return an Observable instead of a Promise?
ABecause Angular HTTPClient uses Observables for request streams and cancellation
BBecause Promises are not supported in Angular
CBecause Observables automatically retry failed requests
DBecause Promises cannot carry headers
Step-by-Step Solution
Solution:
  1. Step 1: Recall Angular HTTPClient design

    Angular HTTPClient uses Observables to support streams, multiple events, and cancellation.
  2. Step 2: Understand why Observables are required in interceptors

    Interceptors must return Observable to integrate with HTTPClient's reactive flow.
  3. Final Answer:

    Because Angular HTTPClient uses Observables for request streams and cancellation -> Option A
  4. Quick Check:

    HTTPClient uses Observables, not Promises [OK]
Quick Trick: Angular HTTPClient is built on Observables, not Promises [OK]
Common Mistakes:
MISTAKES
  • Thinking Promises are unsupported
  • Assuming Observables auto-retry requests
  • Confusing headers with async types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes