The SDK provides helpers for cursor-based pagination to simplify fetching large datasets.
import { FluxaClient } from '@savitura/fluxa';
const client = new FluxaClient({ /* config */ });
const { nodes, pageInfo } = await client.transfers.list(
{ from: '0x123...' },
{ orderBy: 'timestamp', orderDirection: 'desc' },
{ first: 50 }
);
console.log(nodes); // Array of transfers
console.log(pageInfo.hasNextPage); // boolean
console.log(pageInfo.endCursor); // string | nullconst client = new FluxaClient({ /* config */ });
for await (const transfer of client.transfers.iterate(
{ from: '0x123...' },
{ orderBy: 'timestamp' }
)) {
console.log(transfer);
// Break early to stop further requests
if (someCondition) break;
}const allTransfers = await client.transfers.listAll(
{ from: '0x123...' },
{ orderBy: 'timestamp' }
);const controller = new AbortController();
setTimeout(() => controller.abort(), 5000); // Abort after 5 seconds
try {
for await (const transfer of client.transfers.iterate(
{ from: '0x123...' },
undefined,
undefined,
controller.signal
)) {
console.log(transfer);
}
} catch (error) {
if (error.name === 'CursorPaginationError') {
console.log('Iteration was aborted');
}
}