Skip to main content

Fetch Post Likes

The Fetch Post Likes feature in the LikeMinds React Feed SDK 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 fetch likes on a post

  1. Use the getPostLikes() function provided by the lmFeedClient object created earlier.
  2. Create an instance of GetPostLikesRequest, as shown in the snippet and pass it to the above method.
  3. Use the response as per your requirement
try {
const getPostLikesRequest = GetPostLikesRequest.builder()
.setPostId("<ENTER_POST_ID>")
.setPage(1)
.setPageSize(10)
.build();
const response = await lmFeedClient.getPostLikes(getPostLikesRequest);
// Use the response as per your requirement.
} catch (error) {
// Use the error as per your requirement.
}

Models

GetPostLikes

VariableTypeDescriptionOptional
postIdstringUnique id of the post whose likes are fetched.
pageintPage number of paginated like data.
pageSizeintPage size for paginated like data.

GetPostLikesResponse

VariableTypeDescriptionOptional
likesRecord<string, Like>List of the likes on the post.✔️
totalCountintTotal count of likes on the post.✔️
usersRecord<string, User>Map of user unique id to user object.✔️