Skip to content

Commit

Permalink
Fix read pages methods (#31)
Browse files Browse the repository at this point in the history
Without the fix listPages method produces this error:

```
return data.items.map((Page) => new Page({ ...Page, docId })); // 
TypeError: Page is not a constructor
```
  • Loading branch information
zomchak-code authored Sep 13, 2024
1 parent 6fa6f71 commit b97d8a0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export class Coda {
// params: limit, pageToken
// https://coda.io/developers/apis/v1#operation/listPages
async listPages(docId: string, params: any): Promise<Page[]> {
const { data } = await this.API.request(`/docs/${docId}/Pages`, params);
return data.items.map((Page) => new Page({ ...Page, docId })); // map all items into Pages
const { data } = await this.API.request(`/docs/${docId}/pages`, params);
return data.items.map((page) => new Page({ ...page, docId })); // map all items into Pages
}

// https://coda.io/developers/apis/v1#operation/getPage
async getPage(docId: string, pageIdOrName: string): Promise<Page> {
const { data } = await this.API.request(`/docs/${docId}/Pages/${pageIdOrName}`);
const { data } = await this.API.request(`/docs/${docId}/pages/${pageIdOrName}`);
return new Page({ ...data, docId });
}

Expand Down

0 comments on commit b97d8a0

Please sign in to comment.