diff --git a/controllers/userController.js b/controllers/userController.js index cf257b0..f853f3f 100644 --- a/controllers/userController.js +++ b/controllers/userController.js @@ -67,11 +67,23 @@ const userController = { }, getUserProfile: async (req, res) => { - const { id } = getUserIdFromJwt(req.headers.authorization); + const id = getUserIdFromJwt(req.headers.authorization); - const result = await userService.getUserProfile(id); + try { + const result = await userService.getUserProfile(id); - return res.status(200).json({ result }); + return res.status(200).json({ + success: true, + message: '프로필 조회에 성공했습니다.', + data: result[0], + }); + } catch (err) { + return res.status(400).json({ + success: false, + message: '프로필 조회에 실패했습니다.', + err: err, + }); + } }, }; diff --git a/models/userModel.js b/models/userModel.js index 66676b0..e5ad938 100644 --- a/models/userModel.js +++ b/models/userModel.js @@ -38,7 +38,7 @@ const userModel = { const connection = await pool.getConnection(); try { - const [rows, fields] = await connection.query('SELECT * FROM member WHERE id = ?', id); + const [rows, fields] = await connection.query('SELECT * FROM member WHERE id = ?', [id]); return rows; } finally { connection.release();