Skip to main content

Fetch Comment Likes

The Fetch Comment Likes feature in the LikeMinds React Feed SDK enables users to retrieve information about the number of likes received by a specific comment. This functionality allows developers to display the total number of likes on a comment, providing users with social validation and engagement metrics.

Steps to fetch likes on a comment

  1. Use the getCommentLikes() function provided by the lmFeedClient object created earlier.
  2. Create an instance of GetCommentLikesRequest, as shown in the snippet and pass it to the above method.
  3. Use the response as per your requirement
try {
const getCommentLikesRequest = GetCommentLikesRequest.builder()
.setPostId(ENTER_POST_ID) // post id of comment whose likes are fetched
.setCommentId(ENTER_COMMENT_ID) // id of comment whose likes are fetched
.setPage(1) // page number for paginated data
.setPageSize(20) // page size for paginated data
.build();
const response = await lmFeedClient.getCommentLikes(getCommentLikesRequest);
// Use the response as per your requirement.
} catch (error) {
// Use the error as per your requirement.
}

Models

GetPostLikes

VariableTypeDescriptionOptional
postIdstringPost ID of the comment whose likes are fetched.
commentIdstringID of the comment whose likes are fetched.
pageintPage number of paginated like data.
pageSizeintPage size for paginated like data.

GetPostLikesResponse

VariableTypeDescriptionOptional
likes[Like][](/feed/react/data/models/like-model)List of the likes on the comment.✔️
totalCountintTotal count of likes on the comment.✔️
usersRecord<string, User>Map of user unique id to user object.✔️