From 18f6afdcf3b847e1b4d9f12c0bd35477e1b66040 Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Thu, 31 Aug 2023 07:34:16 +0300 Subject: [PATCH] :zap: strapiApiRequestAllItems fix --- packages/nodes-base/nodes/Strapi/GenericFunctions.ts | 2 +- packages/nodes-base/nodes/Strapi/Strapi.node.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/nodes/Strapi/GenericFunctions.ts b/packages/nodes-base/nodes/Strapi/GenericFunctions.ts index be253882fa710..a2b1e0fb4ef7c 100644 --- a/packages/nodes-base/nodes/Strapi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Strapi/GenericFunctions.ts @@ -97,9 +97,9 @@ export async function strapiApiRequestAllItems( body: IDataObject = {}, query: IDataObject = {}, headers: IDataObject = {}, + apiVersion: string = 'v3', ) { const returnData: IDataObject[] = []; - const { apiVersion } = await this.getCredentials('strapiApi'); let responseData; if (apiVersion === 'v4') { diff --git a/packages/nodes-base/nodes/Strapi/Strapi.node.ts b/packages/nodes-base/nodes/Strapi/Strapi.node.ts index 5e12907a79cc8..ae610b0470f47 100644 --- a/packages/nodes-base/nodes/Strapi/Strapi.node.ts +++ b/packages/nodes-base/nodes/Strapi/Strapi.node.ts @@ -9,7 +9,6 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, - CredentialInformation, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -145,14 +144,14 @@ export class Strapi implements INodeType { const authenticationMethod = this.getNodeParameter('authentication', 0); - let apiVersion: CredentialInformation; + let apiVersion: string; if (authenticationMethod === 'password') { const { jwt } = await getToken.call(this); - apiVersion = (await this.getCredentials('strapiApi')).apiVersion; + apiVersion = (await this.getCredentials('strapiApi')).apiVersion as string; headers.Authorization = `Bearer ${jwt}`; } else { - apiVersion = (await this.getCredentials('strapiTokenApi')).apiVersion; + apiVersion = (await this.getCredentials('strapiTokenApi')).apiVersion as string; } for (let i = 0; i < length; i++) { @@ -252,6 +251,7 @@ export class Strapi implements INodeType { {}, qs, headers, + apiVersion, ); } else { qs['pagination[pageSize]'] = this.getNodeParameter('limit', i); @@ -295,6 +295,7 @@ export class Strapi implements INodeType { {}, qs, headers, + apiVersion, ); } else { qs._limit = this.getNodeParameter('limit', i);