Rest API - HTTP Status Codes
You have this Express.js code snippet:
What is the problem if the client sends an empty JSON body?
app.post('/users', (req, res) => {
if (!req.body.email) {
res.status(422).send({ error: 'Email is required' });
} else {
res.status(201).send({ message: 'User created' });
}
});What is the problem if the client sends an empty JSON body?
