What belongs in an Angular HTTP interceptor, and what should remain local?
Understand the idea, explain it in your own words and use the rubric to find your next learning gap.
The idea behind the question
An interceptor can handle cross-cutting request or response behavior. Request cloning, interceptor order and the destination of sensitive headers matter when centralizing that behavior.
An authentication interceptor must attach a token only to the application's trusted API, not every third-party request made by a feature.
A practical way to learn it
Implement and test a trusted-API header interceptor. Include a third-party request that must receive no credential and a failing response that must reach the caller.
Open Angular project studioThe related tool opens separately; your interview answer stays here. Written practice is self-guided, without automatic code grading.
Build an explanation you understand
- State what the concept does in plain language.
- Apply it to the example and make your assumptions explicit.
- Explain a trade-off, failure case and how you would test it.
- Distinguish your actual experience from a proposed approach.
How would you explain it?
Single-question timers reset on refresh. Full mock sessions can resume from this browser.
Strengthen your explanation
Compare reasoning, not identical wording. Reference answers describe a possible approach; replace hypothetical statements with truthful details from your own work.
One way to answer
I would keep shared concerns such as approved API headers or request tracing in an interceptor and leave feature-specific validation and user messaging near the feature. I would clone immutable request objects when changing them, scope credentials to trusted destinations and understand the order of the interceptor chain. Automatic retries require an explicit policy for safe methods and idempotent mutations. I would test matching and non-matching URLs, existing headers, error propagation and cancellation. A centralized interceptor should not swallow failures or turn every response into a misleading success.
What a strong explanation should cover
Tick only the points your own answer addresses. This is self-assessment, not AI scoring.
0 / 3 points self-reportedWatch out for
- Attaching an application access token to all outgoing URLs.
Now go one level deeper
- How would concurrent unauthorized responses avoid repeated refresh attempts?
- Where should a field-level validation message be handled?
Further reading
Further-reading links support learning; the reference is Sukoaa-authored, not an official employer answer key.