Bird
0
0

What does the res.sendStatus(500) method do in an Express response?

easy📝 Conceptual Q1 of 15
Node.js - HTTP Module
What does the res.sendStatus(500) method do in an Express response?
ASets status code to 500 and sends 'Internal Server Error' text
BOnly sets status code to 500 without sending a response
CSends a JSON object with status 500
DRedirects the client to an error page
Step-by-Step Solution
Solution:
  1. Step 1: Understand res.sendStatus behavior

    The method sets the HTTP status code and sends its standard message as the response body.
  2. Step 2: Apply to status 500

    Status 500 corresponds to 'Internal Server Error', so it sends that text with code 500.
  3. Final Answer:

    Sets status code to 500 and sends 'Internal Server Error' text -> Option A
  4. Quick Check:

    res.sendStatus(500) = sends status 500 with message [OK]
Quick Trick: res.sendStatus(code) sends code and default message [OK]
Common Mistakes:
  • Thinking it only sets status without sending
  • Confusing with res.status() which doesn't send
  • Assuming it sends JSON automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes