From c4022de06118b3c32923d4a54359a2985109960b Mon Sep 17 00:00:00 2001 From: Yashraj Jain Date: Sun, 16 Jul 2023 18:50:53 +0530 Subject: [PATCH] added update profile --- README.md | 0 routes/user.js | 13 +++++++++++++ vercel.json | 14 -------------- 3 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 README.md delete mode 100644 vercel.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/routes/user.js b/routes/user.js index e08e011..8339066 100644 --- a/routes/user.js +++ b/routes/user.js @@ -73,6 +73,19 @@ userRouter.post("/api/user/update-address", auth, async (request, response) => { } }); +userRouter.post("/api/user/update", auth, async (request, response) => { + try { + const { address, name } = request.body; + let user = await User.findById(request.user); + user.address = address; + user.name = name; + user = await user.save(); + response.json(user); + } catch (error) { + response.status(500).json({ error: error.message }); + } +}); + userRouter.post("/api/user/order-product", auth, async (request, response) => { try { const { cart, totalPrice, address } = request.body; diff --git a/vercel.json b/vercel.json deleted file mode 100644 index 5c82b11..0000000 --- a/vercel.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "version":2, - "builds":[ - { - "src":"./index.js", - "use":"@vercel/node" - } - ], - "routes":[{ - "src":"/{.*}", - "dest":"/" - }] - -} \ No newline at end of file