Rest API - HTTP Status Codes
You have this Express.js route handler:
What is the problem with this code when a user is not found?
app.get('/users/:id', (req, res) => {
const users = {1: 'Alice', 2: 'Bob'};
const user = users[req.params.id];
if (!user) {
res.status(404);
}
res.send(user);
});What is the problem with this code when a user is not found?
