Skip to main content
InterviewHubPRO
Section Overview
Q174

Question 174 of 283

Part 7: Change Detection, Security (XSS/Sanitizer) & Interceptors (151 - 176)

61%
Angular Master (283 Qs)•Part 7: Change Detection, Security (XSS/Sanitizer) & Interceptors (151 - 176)

What are the applications of HTTP interceptors?

junior LevelMost AskedCode ExampleChange DetectionSecurity & AuthHTTP & REST APIs

The HTTP Interceptors can be used for different variety of tasks,

  1. Authentication
  2. Logging
  3. Caching
  4. Fake backend
  5. URL transformation
  6. Modifying headers

Practical Code Example

typescript
// HTTP Interceptor Applications:
// 1. Adding Bearer Authorization tokens
// 2. Global error logging and redirecting on 401
// 3. Showing / hiding global loading spinners
// 4. Request retry on transient 5xx network errors