File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,6 +164,37 @@ On timeout, an `APIConnectionTimeoutError` is thrown.
164164
165165Note that requests which time out will be [ retried twice by default] ( #retries ) .
166166
167+ ## Auto-pagination
168+
169+ List methods in the Grid API are paginated.
170+ You can use the ` for await … of ` syntax to iterate through items across all pages:
171+
172+ ``` ts
173+ async function fetchAllWorkbooks(params ) {
174+ const allWorkbooks = [];
175+ // Automatically fetches more pages as needed.
176+ for await (const workbookListResponse of client .workbooks .list ({ limit: 50 })) {
177+ allWorkbooks .push (workbookListResponse );
178+ }
179+ return allWorkbooks ;
180+ }
181+ ```
182+
183+ Alternatively, you can request a single page at a time:
184+
185+ ``` ts
186+ let page = await client .workbooks .list ({ limit: 50 });
187+ for (const workbookListResponse of page .items ) {
188+ console .log (workbookListResponse );
189+ }
190+
191+ // Convenience methods are provided for manually paginating:
192+ while (page .hasNextPage ()) {
193+ page = await page .getNextPage ();
194+ // ...
195+ }
196+ ```
197+
167198## Default Headers
168199
169200We automatically send the ` X-Client-Name ` header set to ` api-sdk ` .
You can’t perform that action at this time.
0 commit comments