I have seen 2 different examples and would like to know which is 'right' or if it doesn't make much difference. Example 1 is sending the response inside the try and example 2 is sending outside of the try block.
Example 1:
try {
await food.save();
res.status(201).send(food);
} catch (err) {
res.status(500).send(err);
}
Example 2:
try {
await food.save();
} catch (err) {
res.status(500).send(err);
}
res.status(201).send(food);