Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
472 B
4
Indexable
Never
const insertSale = async (req, res) => {
  const sale = req.body;
  try {
    const insertedSaleID = await salesService.insertProductIntoSale(sale);
    const productsSold = await salesService.getSaleByIdService(insertedSaleID)
      .then((item) => item.map(({ productId, quantity }) => ({ productId, quantity })));
    res.status(201).json({ id: insertedSaleID, itemsSold: productsSold });
  } catch (error) {
    res.status(500).json({ message: error.message });
  }
};
Leave a Comment