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
- Create a GetPostRequest object using
GetPostRequest.builder()
class by passing all the required parameters. - Call
getPost()
function using the instance ofLMFeedClient
. - 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
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
postId | String | Unique id of the post fetched. | |
page | Int | Page number of paginated comment data on the post. | |
pageSize | Int | Page size for paginated comment data on the post. |
GetPostResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
post | Post | Object 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. |