Skip to content

Commit

Permalink
fix baserow pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
narthur committed May 6, 2024
1 parent 2c7d324 commit e6b6941
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 e6b6941

Please sign in to comment.