Challenge - 5 Problems
Status Code Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding HTTP status codes in Express
Which HTTP status code should you use in Express when a client sends a request with missing required data?
Attempts:
2 left
💡 Hint
Think about what status code means the client made a bad request.
✗ Incorrect
400 Bad Request means the server cannot process the request due to client error, such as missing data.
❓ component_behavior
intermediate2:00remaining
Express response status for successful resource creation
What status code does Express typically send when a new resource is successfully created?
Attempts:
2 left
💡 Hint
This code means the server created something new.
✗ Incorrect
201 Created indicates that the request was successful and a new resource was created.
📝 Syntax
advanced2:00remaining
Correct usage of status codes in Express response
Which Express code snippet correctly sends a 404 status with a JSON error message?
Attempts:
2 left
💡 Hint
Check the chaining and method usage for setting status and sending JSON.
✗ Incorrect
res.status(404).json(...) sets the status code and sends JSON correctly.
❓ state_output
advanced2:00remaining
Output status code for unauthorized access in Express
What status code will Express send if you use
res.status(401).send('Unauthorized')?Express
app.get('/secret', (req, res) => { res.status(401).send('Unauthorized'); });
Attempts:
2 left
💡 Hint
The status code you set is sent as the HTTP response status.
✗ Incorrect
res.status(401) sets the HTTP status to 401 Unauthorized, and send() sends the response body.
🔧 Debug
expert2:00remaining
Identify the error in status code usage
What error occurs when running this Express code snippet?
app.get('/data', (req, res) => {
res.status(201).send('Created');
res.status(200).send('OK');
});Express
app.get('/data', (req, res) => { res.status(201).send('Created'); res.status(200).send('OK'); });
Attempts:
2 left
💡 Hint
Think about sending multiple responses in one request.
✗ Incorrect
Express throws an error if you try to send more than one response for a single request.