I figured it out.
I needed to pass express.json()
as an argument when calling the user controller endpoint.
api/src/routes/user.ts
:
router.put("/api/user/:userId", express.json(), userController.updateUser);
api/src/controllers/user.ts
:
exports.updateUser = asyncHandler(async (req: any, res: any, next: any) => { const { userId } = req.params; const data = req.body; const user = await updateUser(userId, data); res.status(200).json({ user }); });
Data is being updated successfully now :)