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.
CoroutineScope(Dispatchers.IO).launch {
// object of GetPostRequest
val getPostRequest = 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()
// get response (LMResponse<GetPostResponse>)
val response = LMFeedClient.getInstance().getPost(getPostRequest)
if (response.success) {
// your function to process the response data
processGetPostResponse(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.
usersMap<String, User>Map of user unique id to user object.
topicsMap<String, Topic>Map of topic id to topic object.
widgetsMap<String, Widget>Map of widget id to widget object.