Skip to content

Commit 576ea87

Browse files
feat(api): update via SDK Studio (#27)
1 parent 339b872 commit 576ea87

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,37 @@ On timeout, an `APIConnectionTimeoutError` is thrown.
164164

165165
Note 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

169200
We automatically send the `X-Client-Name` header set to `api-sdk`.

0 commit comments

Comments
 (0)