Skip to content

Commit

Permalink
Merge pull request #38 from narthur/get-all
Browse files Browse the repository at this point in the history
fix baserow pagination
  • Loading branch information
narthur committed May 6, 2024
2 parents a512c9f + e6b6941 commit 2300c93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ describe("Factory", () => {
vi.mocked(client.get)
.mockResolvedValue({
data: {
results: [],
results: [{}],
next: null,
},
})
.mockResolvedValueOnce({
data: {
results: [{}],
next: "the_next_url",
},
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export class Factory {
options: Record<string, unknown> & { page?: number } = {},
accumulator: R[] = [],
): Promise<R[]> {
const { results } = await this.sdk.listRows<R>(tableId, options);
if (results.length === 0) {
const { results, next } = await this.sdk.listRows<R>(tableId, options);
if (!next) {
return accumulator;
}
accumulator.push(...results);
Expand Down

0 comments on commit 2300c93

Please sign in to comment.