fixr
(Freddie Peña)
2019 年 8 月 28 日午後 4:24
1
みなさん、こんにちは!
このトピック と同様に、/latest.json(トピック )エンドポイントでの適切なページネーション方法を探しています。特に、最後のページをどうやって知るかが知りたいです。
取得すべき結果がまだ残っている場合、レスポンスには次のページを示す "more_topics_url": "/latest?page=X" が含まれていることは分かりました。しかし、私のテストでは、結果がもうない場合でも、このフィールドに別のページが返ってくるようです。
最後のページに到達したことを判断する適切な方法はありますか?
よろしくお願いいたします!
Falco
(Falco)
2019 年 8 月 28 日午後 4:35
2
fixr:
However, from my tests, seems like even when there are no more results, we get another page under this field.
I can’t reproduce this.
For example, you can request
https://meta.discourse.org/c/site-feedback/blog/l/latest.json?page=1
that contains 30 topics and a more_topics_url with "/c/site-feedback/blog/l/latest?page=2".
Then you request that and get 25 more topics and a missing more_topics_url because it’s the end.
「いいね!」 2
fixr
(Freddie Peña)
2019 年 8 月 29 日午後 1:36
3
Thanks for such quick response and for checking it out!
You’re right. I was messing on my development environment on the per_page settings trying to avoid creating 30+ topics to test this, and came across this method , but changing it there seems to have the side-effect I mentioned, though returning the amount of results I set there.
Seems like passing ?per_page=X doesn’t have any effect on this endpoint (following your example: https://meta.discourse.org/c/site-feedback/blog/l/latest.json?page=1&per_page=5 , still returns 30 rows). Is there a proper way to adjust this setting?
Thanks again in advance!
「いいね!」 2
この per_page の機能にも興味があります。
「いいね!」 1