Skip to content

Commit 4b0b0aa

Browse files
authored
Merge pull request #62 from InserToken/feat/17-pracMain/minseon
[modify] userstock 수정 #2
2 parents 5762d17 + 978a55f commit 4b0b0aa

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

routes/userStock.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ router.post("/", authenticate, async (req, res) => {
3131
} catch (err) {
3232
if (err.code === 11000) {
3333
// 이미 연동된 경우 DB에서 해당 유저의 주식 다시 조회해서 내려주기!
34-
const existingStocks = await UserStock.find({ user_id: userId });
34+
const existingStocks = await UserStock.find({ user_id: userId }).populate(
35+
"stock_code"
36+
);
3537
// 필요한 정보만 추리기
3638
const formatted = existingStocks.map((s) => ({
3739
pdno: s.stock_code,
38-
prdt_name: s.company || "", // company 필드가 없다면 적절히 수정!
40+
prdt_name: s.stock_code.name || "", // company 필드가 없다면 적절히 수정!
3941
}));
4042

4143
return res.status(200).json({

0 commit comments

Comments
 (0)