likes api

This commit is contained in:
Primakov Alexandr Alexandrovich 2023-11-03 15:07:54 +03:00
parent 25b3320665
commit 38064eff2b

View File

@ -33,7 +33,10 @@ router.post('/toggle-like', (req, res) => {
const { id, charId } = req.body
if (charLikes[charId]) {
charLikes[charId].likes.push(id)
const currentLikes = new Set(charLikes[charId].likes)
currentLikes.add(id)
charLikes[charId].likes = [...currentLikes]
} else {
charLikes[charId] = { likes: [id] }
}