diff options
author | Mateja <mail@matejamaric.com> | 2021-07-27 18:32:14 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2021-07-27 18:32:14 +0200 |
commit | 306c59e56c5038d13f94b9477bcdd060ab282ee6 (patch) | |
tree | 29e4fb6aae725256033e271fbdbdc655a41938e7 /server/controllers | |
parent | 4999a967fd11db8e5142b0a14c0c3f37283290df (diff) | |
download | mevn-ecommerce-306c59e56c5038d13f94b9477bcdd060ab282ee6.tar.gz mevn-ecommerce-306c59e56c5038d13f94b9477bcdd060ab282ee6.zip |
Add API endpoint for paid orders.
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/transaction.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/server/controllers/transaction.js b/server/controllers/transaction.js index 9edb778..5143c2d 100644 --- a/server/controllers/transaction.js +++ b/server/controllers/transaction.js @@ -127,6 +127,21 @@ module.exports = { res.status(500).json({status: "Couldn't update order in database!"}) console.error(err); }); + }, + + async showPaid(req, res) { + const orders = await Order.find({status: 'paid'}); + let formattedResponse = []; + + orders.forEach(order => { + formattedResponse.push({ + shipping: order.shipping, + items: order.items, + updatedAt: order.updatedAt + }); + }); + + res.json(formattedResponse); } }; |