问题
When asking for a list of courses (or any list), if the list is empty a nextPageToken is still returned, there may be a very good reason for this, but maybe not. It makes it seem like there is still more information to get. I message saying "no more items" or something would be more useful.
I think is happening because we had a lot of courses, then they were all deleted.
I used this page to help test. https://developers.google.com/classroom/reference/rest/v1/courses/list
回答1:
There is a known issue that although deleted courses aren't returned in a response, they still use up spots in the response, sometimes leading to sparse or empty pages of results. In this case however the nextPageToken
is actually correct, as there may be non-deleted courses returned after the first page. The paging logic should always be that you continue to fetch pages until the nextPageToken
field is missing, regardless of how many items are returned in the response.
来源:https://stackoverflow.com/questions/32567498/incorrect-nextpagetoken-bug-in-google-classroom-api-v1