Bird
0
0

What is wrong with this health check endpoint?

medium📝 Analysis Q7 of 15
Microservices - Resilience Patterns
What is wrong with this health check endpoint?
app.get('/health', (req, res) => {
  res.send('OK');
  res.status(200);
});
AMissing database check
BUsing GET instead of POST
CSetting status after sending response
DNot returning JSON response
Step-by-Step Solution
Solution:
  1. Step 1: Understand response order in HTTP

    HTTP status must be set before sending the response body.
  2. Step 2: Identify the mistake in code

    res.status(200) is called after res.send('OK'), so status is ignored.
  3. Final Answer:

    Setting status after sending response -> Option C
  4. Quick Check:

    Set status before sending response [OK]
Quick Trick: Always set status before sending response body [OK]
Common Mistakes:
MISTAKES
  • Setting status after sending response
  • Ignoring response order rules
  • Assuming default status is always 200

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes