Bird
0
0

What will be the output if this interceptor is applied?

medium📝 component behavior Q5 of 15
NestJS - Interceptors
What will be the output if this interceptor is applied?
intercept(context, next) {
  return next.handle().pipe(map(() => 'fixed response'));
}
AEvery response will be replaced with the string 'fixed response'
BThe original response will be returned unchanged
CThe response will be an empty object
DThe response will be an error
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the map function

    The map function ignores the original data and returns 'fixed response' string.
  2. Step 2: Understand the effect on response

    All responses are replaced by this fixed string.
  3. Final Answer:

    Every response will be replaced with the string 'fixed response' -> Option A
  4. Quick Check:

    map returns fixed string replacing response [OK]
Quick Trick: map(() => value) replaces all responses with value [OK]
Common Mistakes:
  • Assuming original data is preserved
  • Expecting an object instead of string
  • Thinking it causes an error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes