Bird
0
0

What will the following Express code send to the client?

medium📝 component behavior Q4 of 15
Node.js - HTTP Module
What will the following Express code send to the client?
app.get('/hello', (req, res) => { res.status(404).send('Not Found'); });
AStatus 500 with body 'Not Found'
BStatus 404 with body 'Not Found'
CStatus 404 with empty body
DStatus 200 with body 'Not Found'
Step-by-Step Solution
Solution:
  1. Step 1: Analyze res.status(404).send()

    res.status(404) sets HTTP status to 404, then .send() sends the string as response body.
  2. Step 2: Confirm status and body sent

    The client receives status 404 and the text 'Not Found'.
  3. Final Answer:

    Status 404 with body 'Not Found' -> Option B
  4. Quick Check:

    res.status().send() sets code and sends body [OK]
Quick Trick: res.status(code).send(body) sends code and text body [OK]
Common Mistakes:
  • Assuming status defaults to 200
  • Expecting empty body with status set
  • Confusing status 404 with 500

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes