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
- Use the
getPost()
function provided by thelmFeedClient
object created earlier. - Create an instance of
GetPostRequest
, as shown in the snippet and pass it to the above method. - Use the response as per your requirement
try {
const getPostRequest = GetPostRequest.builder()
.setPostId("<ENTER_POST_ID>")
.setPage(1)
.setPageSize(10)
.build();
const response = await lmFeedClient.getPost(getPostRequest);
// Use the response as per your requirement.
} catch (error) {
// Use the error as per your requirement.
}
Models
GetPostRequest
Variable | Type | Description | Optional |
---|---|---|---|
postId | string | Unique id of the post fetched. | |
page | int | page number | ✔️ |
pageSize | int | number of items per page | ✔️ |
GetPostResponse
Variable | Type | Description | Optional |
---|---|---|---|
post | Post | Object of the created post. | ✔️ |
users | Record<string, User> | Map of user unique id to user object. | ✔️ |
topics | Record<string, Topic> | Map of topic id to topic object. | ✔️ |
widgets | Record<string, Widget> | Map of widgets. | ✔️ |