Bird
0
0

Consider this Angular interceptor code snippet:

medium📝 Predict Output Q4 of 15
Angular - HTTP Client
Consider this Angular interceptor code snippet:
intercept(req, next) {
  const token = 'abc123';
  const modifiedReq = req.clone({ headers: req.headers.set('Authorization', `Token ${token}`) });
  return next.handle(modifiedReq);
}

What will be the exact value of the Authorization header in the outgoing HTTP request?
ABearer abc123
BToken abc123
Cabc123
DAuthorization: Token abc123
Step-by-Step Solution
Solution:
  1. Step 1: Review header setting

    The header is set as 'Authorization' with value `Token ${token}`.
  2. Step 2: Substitute token value

    Token is 'abc123', so header value becomes 'Token abc123'.
  3. Final Answer:

    Token abc123 -> Option B
  4. Quick Check:

    Check string interpolation [OK]
Quick Trick: Header value matches string template exactly [OK]
Common Mistakes:
MISTAKES
  • Assuming 'Bearer' prefix instead of 'Token'
  • Including 'Authorization:' in header value
  • Using token alone without prefix

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes