Bird
0
0

Which method is used to set the HTTP status code without sending the response immediately in Express?

easy📝 Conceptual Q2 of 15
Node.js - HTTP Module
Which method is used to set the HTTP status code without sending the response immediately in Express?
Ares.status()
Bres.send()
Cres.sendStatus()
Dres.json()
Step-by-Step Solution
Solution:
  1. Step 1: Identify methods that set status code

    res.status() sets the status code but does not send the response immediately.
  2. Step 2: Compare with other methods

    res.sendStatus() sets and sends; res.send() and res.json() send data but don't set status alone.
  3. Final Answer:

    res.status() -> Option A
  4. Quick Check:

    res.status() sets status without sending [OK]
Quick Trick: Use res.status() to set code before sending response [OK]
Common Mistakes:
  • Using res.sendStatus() expecting no send
  • Confusing res.send() as status setter
  • Assuming res.json() sets status code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes