mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
974 B
974 B
sidebar_position
sidebar_position |
---|
6 |
Toggle post like
Toggles the like status of a post.
```js async function PostModel.toggleLike(payload) ```
[Object] Payload
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
post_id | string | false | ||
to | Boolean | true | Set like to true or false |
Success Response
Parameter | Type | Content |
---|---|---|
data | Object | like-status-object |
Examples
Basic usage
const like = await PostModel.toggleLike({
post_id: "0000",
})
console.log(like)
// result: {
// post_id: "0000",
// liked: true,
// count: 1,
// }
Specify status
const like = await PostModel.toggleLike({
post_id: "0000",
to: false
})
console.log(like)
// result: {
// post_id: "0000",
// liked: false,
// count: 0,
// }