Skip to content

Commit

Permalink
friend list page fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
singharaj-usai committed Oct 16, 2024
1 parent e6d1da1 commit a549695
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions server/functions/api/routes/friends.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ router.post(
// Get friend requests
router.get('/friend-requests', authenticateToken, async (req, res) => {
try {
const user = await User.findById(req.user.userId).populate(
const user = await User.findOne({ userId: req.user.userId }).populate(
'friendRequests',
'username'
);
Expand All @@ -178,7 +178,10 @@ router.get('/friend-requests', authenticateToken, async (req, res) => {
// Get friends list
router.get('/', authenticateToken, async (req, res) => {
try {
const user = await User.findById(req.user.userId).populate('friends', 'username');
const user = await User.findOne({ userId: req.user.userId }).populate(
'friends',
'username'
);
res.json(user.friends);
} catch (error) {
res.status(500).json({ error: 'Error fetching friends list' });
Expand Down

0 comments on commit a549695

Please sign in to comment.