官术网_书友最值得收藏!

Listing all comments for a particular post

  • Request: GET /posts/1/comments HTTP/1.1
  • Response:
{
data:[
{
id:1, comment:"Awesome Post", post_id:1, link: "/comments/1"
}, {
id:2, comment:"Another post comment", post_id:1, link: "/comments/2"
}
],
total_count: 2,
limit: 10,
pagination: {
first_page: "/posts/1/comments?page=1",
last_page: "/posts/1/comments?page=1",
page=1
}
}
  • Response Code: 200 OK

As you can see, a post's comments listing is very similar to a blog post's listing. And it has total_count and pagination in the same way. It shows the first and last page right now because total_count for the records is only 2. So there is no next or previous page. Otherwise, we should also have to show the next and previous links in pagination.

Normally, you don't see pagination with comments on blogs, but it is better to keep it consistent to have pagination in the listing. Because there can be lot of comments for a post, we should apply some limit to it, so we will need pagination.

主站蜘蛛池模板: 洮南市| 游戏| 汉中市| 新巴尔虎右旗| 故城县| 洪雅县| 嘉义市| 淅川县| 连南| 竹山县| 华池县| 凤台县| 泰来县| 紫金县| 龙井市| 天门市| 宣威市| 昭苏县| 贵溪市| 龙川县| 龙门县| 虎林市| 邹平县| 江北区| 南溪县| 威海市| 双牌县| 汝城县| 普定县| 兴义市| 石首市| 张家口市| 南涧| 富川| 金沙县| 乌拉特前旗| 安新县| 新营市| 广元市| 利津县| 长兴县|