diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 714f28eae5..ec9895c483 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -2005,7 +2005,7 @@ export async function getCredentials { - const type = typeof credType === 'string' ? credType : credType.name; + const type = typeof credType === 'string' ? credType : new credType().name; // Get the NodeType as it has the information if the credentials are required const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion); if (nodeType === undefined) { diff --git a/packages/nodes-base/nodes/Strapi/GenericFunctions.ts b/packages/nodes-base/nodes/Strapi/GenericFunctions.ts index 4dcdc5466a..5996ef2e3d 100644 --- a/packages/nodes-base/nodes/Strapi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Strapi/GenericFunctions.ts @@ -9,7 +9,9 @@ import type { JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { StrapiApiCredential } from '@credentials/StrapiApi.credentials'; + +import { StrapiApi } from '@credentials/StrapiApi.credentials'; +import { StrapiTokenApi } from '@credentials/StrapiTokenApi.credentials'; export const removeTrailingSlash = (url: string) => { if (url.endsWith('/')) { @@ -28,13 +30,9 @@ export async function strapiApiRequest( headers: IDataObject = {}, ) { const authenticationMethod = this.getNodeParameter('authentication', 0); - let credentials: Pick; - - if (authenticationMethod === 'password') { - credentials = await this.getCredentials('strapiApi'); - } else { - credentials = await this.getCredentials('strapiTokenApi'); - } + const credentials = await this.getCredentials( + authenticationMethod === 'password' ? StrapiApi : StrapiTokenApi, + ); const url = removeTrailingSlash(credentials.url);