The Likes API allows users to view and manage likes on a specific post. This includes retrieving users who have liked a post with pagination and search functionality. Real-time updates for likes are handled via WebSockets.
Note: Ensure that all API requests include a valid JSON Web Token (JWT) in the x-token
header to authenticate users.
Retrieve the list of users who liked the post specified by :postId
, with pagination and optional search.
Request Headers:
x-token: <JWT>
Request Body:
{
"page": <number> (optional, defaults to 1),
"limit": <number> (optional, defaults to 10),
"searchQuery": <string> (optional, for filtering by user name)
}
Response:
{
"totalLikes": <number>,
"totalPages": <number>,
"page": <number>,
"likes": [
{
"_id": "userId",
"profileImage": "imageUrl",
"firstName": "John",
"lastName": "Doe"
}
]
}
The Likes feature uses WebSockets to handle real-time updates for likes. This ensures that any changes to likes are instantly reflected on the UI for all connected clients.
Note: Ensure that all API requests include a valid JSON Web Token (JWT) in the x-token
header to authenticate users.
Explanation: The WebSocket implementation for likes operates with the following events:
postId
. The server fetches the post and sends an update to the client.Warning: Notifications are currently supported only for likes on posts. Notifications for comments and other features will be available in a future update.