mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Use correct credential name
This commit is contained in:
parent
efc809592a
commit
768cecedc5
|
@ -2005,7 +2005,7 @@ export async function getCredentials<T extends object = ICredentialDataDecrypted
|
|||
connectionInputData?: INodeExecutionData[],
|
||||
itemIndex?: number,
|
||||
): Promise<T> {
|
||||
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) {
|
||||
|
|
|
@ -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<StrapiApiCredential, 'apiVersion' | 'url'>;
|
||||
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue