Fetch Comment
The LikeMinds React feed SDK provides feature to fetch Comment. Elevate user interaction in your react app with by integrate a powerful and customizable comment section that encourages dynamic conversations among users.
Steps to fetch a comment
- Use the
getComments()
function provided by thelmFeedClient
object created earlier. - Create an instance of
GetCommentsRequest
, as shown in the snippet and pass it to the above method. - Use the response as per your requirement
try {
const GetCommentsRequest = GetCommentsRequest.builder()
.setPostId("<ENTER_POST_ID>") // id of the post on which member has commented
.setCommentId("<ENTER_COMMENT_ID>")
.setPage(1)
.setPageSize(10)
.build();
const response = await lmFeedClient.getComments(GetCommentsRequest);
// Use the response as per your requirement.
} catch (error) {
// Use the error as per your requirement.
}
note
Same function can be used to fetch a reply as well. Just pass the id of the reply as comment id.
Models
GetCommentRequest
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
postId | string | Post ID of the comment fetched. | |
commentId | string | ID of the comment fetched. | |
page | int | Page number of paginated replies on comment. | |
pageSize | int | Page size for paginated creplies on comment. |
GetCommentResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
comment | Reply | Object of the added comment. | |
users | Record<string, User> | Map of user unique id to user object. | ✔️ |