From 1deecbffb8a9add45a4316e08c4b3e1d082f9583 Mon Sep 17 00:00:00 2001 From: jason-jackson Date: Thu, 20 Nov 2025 18:07:29 -0500 Subject: [PATCH 1/2] don't fail if missing paginator --- paginated_request.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/paginated_request.js b/paginated_request.js index df9097a..f93a9d7 100644 --- a/paginated_request.js +++ b/paginated_request.js @@ -2,7 +2,7 @@ export default defineComponent({ name: "Paginated HTTP Request", description: "Creates a HTTP Request until end of paginated data or timeout is reached", key: "paginated_http_request", - version: "0.0.1", + version: "0.0.2", type: "action", props: { @@ -47,12 +47,15 @@ export default defineComponent({ }, methods: { get_pagination_index() { - for (const key in this.http_request.params) { - if (this.http_request.params[key].name == this.paginator) { - return key - } + let i = this.http_request.params.findIndex(p => p.name == this.paginator) + if (i < 0) { + i = this.http_request.params.length + this.http_request.params.push({ + "name": this.paginator, + "value": "0" + }) } - return null + return i }, get_response_data(resp) { let data = resp @@ -76,10 +79,6 @@ export default defineComponent({ }, async run({ $ }) { const i = await this.get_pagination_index() - if (i === null) { - throw new Error("Pagination parameter not set") - } - const start = Date.now() const results = [] let data = [] From 358a4daa3352431fd064ce61e6603e0751531d43 Mon Sep 17 00:00:00 2001 From: jason-jackson Date: Thu, 20 Nov 2025 18:08:44 -0500 Subject: [PATCH 2/2] use titleCase for function names --- paginated_request.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/paginated_request.js b/paginated_request.js index f93a9d7..2710f17 100644 --- a/paginated_request.js +++ b/paginated_request.js @@ -46,7 +46,7 @@ export default defineComponent({ } }, methods: { - get_pagination_index() { + getPaginationIndex() { let i = this.http_request.params.findIndex(p => p.name == this.paginator) if (i < 0) { i = this.http_request.params.length @@ -57,14 +57,14 @@ export default defineComponent({ } return i }, - get_response_data(resp) { + getResponseData(resp) { let data = resp for (const field of this.data_field.split(".")) { data = data[field] } return data }, - handle_timeout(start) { + handleTimeout(start) { const duration = Date.now() - start if (this.timeout && duration > this.timeout * 1000) { const msg = `Timeout reached at ${duration / 1000} seconds` @@ -78,14 +78,14 @@ export default defineComponent({ } }, async run({ $ }) { - const i = await this.get_pagination_index() + const i = await this.getPaginationIndex() const start = Date.now() const results = [] let data = [] let count = 1 do { const resp = await this.http_request.execute() - data = await this.get_response_data(resp) + data = await this.getResponseData(resp) if (!Array.isArray(data)) { throw new Error(`Response data is not an array: ${typeof data}`); @@ -97,7 +97,7 @@ export default defineComponent({ results.push(...data) - if (await this.handle_timeout(start)) { + if (await this.handleTimeout(start)) { break } count++