Auto-pagination
Using auto-pagination with the Trigger.dev management API
Paginated list methods in the management API (runs, schedules, queues, deployments, and others) support auto-pagination.
You can use for await … of syntax to iterate through items across all pages:
import { } from "@trigger.dev/sdk";
async function fetchAllRuns() {
const allRuns = [];
for await (const run of .list({ limit: 10 })) {
allRuns.(run);
}
return allRuns;
}You can also use helpers on the return value from any list method to get the next/previous page of results:
import { } from "@trigger.dev/sdk";
async function main() {
let page = await .list({ limit: 10 });
for (const run of page.data) {
.(run);
}
while (page.hasNextPage()) {
page = await page.getNextPage();
// ... do something with the next page
}
}Was this page helpful?
Last updated
Edit on GitHub