Skip to main content

Fetch Post

Retrieves a specific post from the server, allowing users to view its content, comments, likes, and other associated information.

Steps to fetch a post

  1. Create a GetPostRequest object using GetPostRequest.builder() class by passing all the required parameters.
  2. Call getPost() function using the instance of LMFeedClient.
  3. Process the response LMResponse<GetPostResponse> as per your requirement.
// object of GetPostRequest
let request = GetPostRequest.builder()
.postId(ENTER_POST_ID) // id of the post fetched
.page(1) // page number for paginated comments
.pageSize(5) // page size for paginated comments
.build()
LMFeedClient.shared.getPost(request) { response in
// response (LMResponse<GetPostResponse>)
if (response.success) {
// your function to process the response data
processResponse(response.data)
} else {
// your function to process error message
processError(response.errorMessage)
}
}

Models

GetPostRequest

VARIABLETYPEDESCRIPTIONOPTIONAL
postIdStringUnique id of the post fetched.
pageIntPage number of paginated comment data on the post.
pageSizeIntPage size for paginated comment data on the post.

GetPostResponse

VARIABLETYPEDESCRIPTIONOPTIONAL
postPostObject of the post fetched.
users[String: User]Dictionary of user unique id to user object.
topics[String: Topic]Map of topic id to topic object.