stack_overflow_nextjs14
stack_overflow_nextjs14 copied to clipboard
fix: return user tags interactions
Remove Static return list and implement dynamic user tags interactions
Static Data
return [ {_id: '1', name: 'tag'}, {_id: '2', name: 'tag2'}]
replace with
// Find the user's interactions where actions equal "ask_question" or "answer" and return tags name without duplicates
const userInteractions = await Interaction.find({
user: user._id,
action: { $in: ["ask_question", "answer"] },
}).distinct("tags");
// Extract tags from user's interactions limited to 5 tags
const tags = await Tag.find({ _id: { $in: userInteractions } }).limit(5);
// return list of tags
return tags;
@mohannadofficial is attempting to deploy a commit to the JS Mastery Pro Team on Vercel.
A member of the Team first needs to authorize it.