Bird
0
0

What does the res.status(404) method do in a Node.js response?

easy📝 Conceptual Q11 of 15
Node.js - HTTP Module
What does the res.status(404) method do in a Node.js response?
ARedirects the client to a page named '404'
BSends the response body with the text '404'
CSets the HTTP status code to 404 (Not Found) for the response
DEnds the response without sending any data
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of res.status()

    This method sets the HTTP status code that tells the browser what happened with the request.
  2. Step 2: Identify the meaning of 404 status code

    Status code 404 means 'Not Found', indicating the requested resource does not exist.
  3. Final Answer:

    Sets the HTTP status code to 404 (Not Found) for the response -> Option C
  4. Quick Check:

    Status code 404 = Not Found [OK]
Quick Trick: Status codes tell browser what happened; 404 means not found [OK]
Common Mistakes:
  • Thinking res.status sends the response body
  • Confusing status code with redirect
  • Assuming res.status ends the response

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes