Skip to content

Commit

Permalink
프로필 조회 API 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
wook-hyung committed Dec 16, 2023
1 parent a18a624 commit 5095705
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
},
};

Expand Down
2 changes: 1 addition & 1 deletion models/userModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5095705

Please sign in to comment.