From 5d98714f41c81cd3b18cac530ad0ea087ecc4283 Mon Sep 17 00:00:00 2001 From: Matt Kirby <MattJKirby@outlook.com> Date: Fri, 14 Apr 2023 15:35:25 +0100 Subject: [PATCH] Fixing the userservice update endpoint --- .../user-service/controllers/appController.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend-services/user-service/controllers/appController.js b/backend-services/user-service/controllers/appController.js index 447acb46..73558768 100644 --- a/backend-services/user-service/controllers/appController.js +++ b/backend-services/user-service/controllers/appController.js @@ -177,9 +177,13 @@ export async function updateUser(req,res){ // update the data UserModel.updateOne({ _id : userId }, body, function(err, data){ + try{ if(err) throw err; - return res.status(201).send({ msg : "Record Updated...!"}); + } catch (error) { + return res.status(401).send({ error }); + } + }) }else{ @@ -187,7 +191,7 @@ export async function updateUser(req,res){ } } catch (error) { - return res.status(401).send({ error }); + return res.status(401).send({ error }); } } -- GitLab