I am making a post request and I want to check if any parameter is not left empty. It is being checked for one parameter but not for both.
app.post("/tshirt/:id", (req, res) => {
const {id} = req.params;
const {logo, size} = req.body;
if(logo === undefined) {
res.status(418).send("It needs a logo");
}
if(size === undefined) {
res.status(418).send("It needs a size");
}
else {
res.status(200).send({
tshirt: ` with your ${logo} is ready`,
size: `${size}`
});
}
})
When no size is passed
When no logo is passed
When both parameters are passed
I want to get the result only when both the parameters are satisfied.