-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Se crea addProductForDelivery para guardar en la base de datos
- Loading branch information
Showing
4 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Backend/controllers/products/productsWthDelivery/addProductsDelivery.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const productsWithDelivery = require('../../../models/productsWithDelivery.js'); | ||
|
||
async function addProductForDelivery(req, res) { | ||
try { | ||
const { | ||
nameClient, | ||
numberContact, | ||
email, | ||
address, | ||
description, | ||
numberProducts, | ||
productsList, | ||
delivery | ||
} = req.body; | ||
|
||
const newProduct = new productsWithDelivery({ | ||
nameClient, | ||
numberContact, | ||
email, | ||
address, | ||
description, | ||
numberProducts, | ||
productsList, | ||
delivery | ||
}); | ||
|
||
const productStored = await newProduct.save(); | ||
|
||
res.status(200).send({ productStored }); | ||
} catch (error) { | ||
res.status(500).send({ message: error.message }); | ||
} | ||
} | ||
|
||
module.exports = { addProductForDelivery }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const express = require('express'); | ||
const { addProductForDelivery } = require('../controllers/products/productsWthDelivery/addProductsDelivery.js'); | ||
const api = express.Router(); | ||
|
||
api.post('/Delivery', addProductForDelivery) | ||
|
||
module.exports = api; |