Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- router.post('/', (req,res,next)=>{
- const product = new Product({
- _id: new mongoose.Types.ObjectId(),
- name: req.body.name,
- price: req.body.price
- });
- product
- .save()
- .then(result =>{
- res.status(201).json({
- message: 'Handling POST requests to /products',
- createdProduct: product
- });
- })
- .catch(err => {
- res.status(500).json(error: err.message);
- });
- });
Add Comment
Please, Sign In to add comment