Skip to content

Commit 25a83dc

Browse files
docs: add more examples
1 parent 8af5fca commit 25a83dc

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

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

132132
Note that requests which time out will be [retried twice by default](#retries).
133133

134+
## Auto-pagination
135+
136+
List methods in the Arcade API are paginated.
137+
You can use the `for await … of` syntax to iterate through items across all pages:
138+
139+
```ts
140+
async function fetchAllUserConnectionResponses(params) {
141+
const allUserConnectionResponses = [];
142+
// Automatically fetches more pages as needed.
143+
for await (const userConnectionResponse of client.admin.userConnections.list()) {
144+
allUserConnectionResponses.push(userConnectionResponse);
145+
}
146+
return allUserConnectionResponses;
147+
}
148+
```
149+
150+
Alternatively, you can request a single page at a time:
151+
152+
```ts
153+
let page = await client.admin.userConnections.list();
154+
for (const userConnectionResponse of page.items) {
155+
console.log(userConnectionResponse);
156+
}
157+
158+
// Convenience methods are provided for manually paginating:
159+
while (page.hasNextPage()) {
160+
page = await page.getNextPage();
161+
// ...
162+
}
163+
```
164+
134165
## Advanced Usage
135166

136167
### Accessing raw Response data (e.g., headers)

0 commit comments

Comments
 (0)