Fetch Post Likes
The getPostLikes()
function allows users to retrieve information about the number of likes received by a specific post. By utilizing this functionality, developers can display the total number of likes on a post and provide users with social validation and engagement metrics.
Steps to Get Post Likes
- Create an instance of
GetPostLikesRequest
with the required parameters:postId
for the post to retrieve likes, and optionally,page
andpageSize
for pagination. - Call the
getPostLikes()
function using the instance of theLMFeedClient
class, passing the request as a parameter. - Use the response as per your requirement.
// Create an instance of GetPostLikesRequest
GetPostLikesRequest request = (GetPostLikesRequestBuilder()
..page(1)
..pageSize(10)
..postId("post_id"))
.build();
// Get the response from calling the function
final GetPostLikesResponse postLikesResponse = await lmFeedClient.getPostLikes(postLikesRequest);
// Process the response, as per requirement
if (postLikesResponse.success) {
// your function to handle successful retrieval of post likes
handlePostLikesSuccess(postLikesResponse.likes, postLikesResponse.totalCount, postLikesResponse.users);
} else {
// your function to handle error message
handlePostLikesError(postLikesResponse.errorMessage);
}
Models
GetPostLikesRequest
List of parameters for the GetPostLikesRequest
class
Variable | Type | Description | Optional |
---|---|---|---|
postId | String | ID of the post to retrieve likes | |
page | int | Page number for pagination | ✔ |
pageSize | int | Number of items per page | ✔ |
GetPostLikesResponse
List of parameters for the GetPostLikesResponse
class
Variable | Type | Description | Optional |
---|---|---|---|
success | bool | API success status | |
errorMessage | String | Error message in case of failure | ✔ |
likes | List<Like > | List of likes for the post | |
totalCount | int | Total count of likes for the post | |
users | Map<String, User > | Map of user UUIDs to User entities |