Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.post("/products", async (req, res) => {
- const { error } = Joi.validate(req.body, productSchema, { abortEarly: false });
- if (error) {
- const errorMessage = error.details.map(({ message, context }) =>
- Object.assign({ message, context })
- );
- return res.status(400).send({ data: errorMessage });
- }
- const product = await Product.create(req.body);
- res.status(201).send();
- });
Add Comment
Please, Sign In to add comment