likes api
This commit is contained in:
parent
25b3320665
commit
38064eff2b
@ -33,7 +33,10 @@ router.post('/toggle-like', (req, res) => {
|
|||||||
const { id, charId } = req.body
|
const { id, charId } = req.body
|
||||||
|
|
||||||
if (charLikes[charId]) {
|
if (charLikes[charId]) {
|
||||||
charLikes[charId].likes.push(id)
|
const currentLikes = new Set(charLikes[charId].likes)
|
||||||
|
currentLikes.add(id)
|
||||||
|
|
||||||
|
charLikes[charId].likes = [...currentLikes]
|
||||||
} else {
|
} else {
|
||||||
charLikes[charId] = { likes: [id] }
|
charLikes[charId] = { likes: [id] }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user