Skip to content

Commit

Permalink
fix: bad opts passing
Browse files Browse the repository at this point in the history
  • Loading branch information
nadhifikbarw committed Dec 27, 2024
1 parent cddcdaf commit 53fcac4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
10 changes: 6 additions & 4 deletions src/comment-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class AirtableCommentQuery {
) {
this.table = table;
this.recordId = recordId;
if (this.opts) this.opts = opts;
if (opts) this.opts = opts;
}

async firstPage() {
Expand Down Expand Up @@ -74,9 +74,11 @@ export class AirtableCommentQuery {
{
query,
async onEachPage(ctx) {
const pageComments = ctx.response?.comments || [];
for (const data of pageComments) {
comments.push(new AirtableComment(table, recordId, data));
if (ctx.response?.comments) {
const pageComments = ctx.response.comments;
for (const data of pageComments) {
comments.push(new AirtableComment(table, recordId, data));
}
}
return true;
},
Expand Down
10 changes: 6 additions & 4 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class AirtableQuery<TFields extends FieldSet> {

constructor(table: AirtableTable<TFields>, opts?: ListRecordsOptions) {
this.table = table;
if (this.opts) this.opts = opts;
if (opts) this.opts = opts;
}

// TODO: support iterator timeout scenario
Expand Down Expand Up @@ -67,9 +67,11 @@ export class AirtableQuery<TFields extends FieldSet> {
body,
method: "POST",
async onEachPage(ctx) {
const pageRecords = ctx.response?.records || [];
for (const data of pageRecords) {
records.push(AirtableRecord.fromData(table, data));
if (ctx.response?.records) {
const pageRecords = ctx.response.records;
for (const data of pageRecords) {
records.push(AirtableRecord.fromData(table, data));
}
}
return true;
},
Expand Down
5 changes: 1 addition & 4 deletions src/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ export class AirtableRecord<
data: RecordData<T>
) {
const rec = new AirtableRecord(table, data.id);
rec._data = data;
rec.fields = data.fields;
rec.createdTime = new Date(data.createdTime);
if (data.commentCount) rec.commentCount = data.commentCount;
rec.setData(data);
return rec;
}

Expand Down

0 comments on commit 53fcac4

Please # to comment.