Docs: Drive pagination code is incorrect
See original GitHub issueAPI v3 https://developers.google.com/drive/api/v3/reference/files/list
Looking at the List documentation (Node at the very least), there is a lot of information that is left out which is fundamental to making paginated requests:
- The pagination parameter is called
nextPageToken
, notpageToken
as it lists. Even my linter tells me that what I’ve written is incorrect, but if I ignore the lint error and submit the request, it works. When using the ‘linter-correct’ version, the request fails. - It appears you must include the same ‘q’ parameter in your request as well
- You must include
fields: 'nextPageToken,files(id, name)'
in the request, even though not including it returns a nextPageToken, it appears to be invalid
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Google drive pagination not working. Empty nextPageToken
Just found the solution: The nextPageToken must be added outside of the files() section. My mistake was that first I put it inside...
Read more >Change a document's page setup: pages or pageless - Android
To change whether a document has pages or is pageless: On your Android phone or tablet, open the Google Docs app. Open a...
Read more >Pagination with rel="next" and rel="prev" - Google Developers
When implemented incorrectly, such as omitting an expected rel="prev" or rel="next" ... and code samples are licensed under the Apache 2.0 License.
Read more >SEO-Friendly Pagination: A Complete Best Practices Guide
Pagination Creates Thin Content. Correct if you have split an article or photo gallery across multiple pages (in order to drive ad revenue...
Read more >Use start cursors and limits to paginate Firestore collections
Explore further. For detailed documentation that includes this code sample, see the following: Paginate data with query cursors · Paginating data with query ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@TaylorDale Thanks for the bug report. Looks like a duplicate to https://github.com/googleapis/google-api-nodejs-client/issues/1885
Your implementation is dependant on your use case but if you wanted to pull all of the data when there is pagination you can do something like the following:
This assumes that nextPageToken is undefined when pagination is finished, which may not be the case with Google APIs, there may be another field that indicates this is the last page of data so deal with it accordingly.
Please note though that is more psuedocode, you’ll need to use the correct Google API methods and more robust error checking is probably needed, but that would be how you’d deal with pagination and have all the data in the data variable.
You might have better luck with further help on Stack Overflow seeing as this isn’t related to the actual bug in the docs 😃