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

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.

主站蜘蛛池模板: 弋阳县| 婺源县| 贞丰县| 明溪县| 克山县| 繁昌县| 常州市| 扶风县| 简阳市| 高平市| 卓尼县| 陆河县| 克东县| 乌拉特后旗| 民县| 宁明县| 红河县| 墨竹工卡县| 宣城市| 灵山县| 通辽市| 乃东县| 额尔古纳市| 镶黄旗| 聊城市| 广饶县| 曲阳县| 宜川县| 商河县| 郁南县| 合阳县| 咸宁市| 阳新县| 兴城市| 承德市| 江山市| 章丘市| 宜良县| 娄底市| 蒙阴县| 大邑县|