Skip to content

Commit 1c54013

Browse files
committed
Refactor template retrieval in create-page-from-database action
- Updated the `listTemplates` method call to use a parameters object for improved readability and maintainability. - Added support for optional `start_cursor` parameter to handle pagination when retrieving templates.
1 parent a09a4f0 commit 1c54013

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

components/notion/actions/create-page-from-database/create-page-from-database.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,15 @@ export default {
115115
label: "Template ID",
116116
description: "The ID of the template to use for the page. [See the documentation](https://developers.notion.com/docs/creating-pages-from-templates) for more information.",
117117
options: async({ prevContext }) => {
118+
const params = {
119+
data_source_id: this.parentDataSource,
120+
};
121+
if (prevContext?.nCursor) {
122+
params.start_cursor = prevContext.nCursor;
123+
}
118124
const {
119125
templates, next_cursor: nCursor,
120-
} = await this.notion.listTemplates({
121-
data_source_id: this.parentDataSource,
122-
start_cursor: prevContext?.nCursor,
123-
});
126+
} = await this.notion.listTemplates(params);
124127
return {
125128
options: templates.map(({
126129
name: label, id: value,

0 commit comments

Comments
 (0)