Bird
0
0

Given this interceptor code snippet, what will be the value of the 'Authorization' header in the outgoing request?

medium📝 component behavior Q13 of 15
Angular - HTTP Client
Given this interceptor code snippet, what will be the value of the 'Authorization' header in the outgoing request?
intercept(req, next) {
  const cloned = req.clone({
    setHeaders: { Authorization: 'Bearer token123' }
  });
  return next.handle(cloned);
}
AAn error will occur due to incorrect syntax
BNo Authorization header will be set
C'token123'
D'Bearer token123'
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the clone method usage

    The code clones the request and sets the 'Authorization' header to 'Bearer token123'.
  2. Step 2: Understand header setting effect

    The cloned request will have the header exactly as set, so the header value is 'Bearer token123'.
  3. Final Answer:

    'Bearer token123' -> Option D
  4. Quick Check:

    Header set to 'Bearer token123' [OK]
Quick Trick: Headers set in clone appear in outgoing request [OK]
Common Mistakes:
MISTAKES
  • Assuming header is missing
  • Confusing header value with token only
  • Thinking syntax causes error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes