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[],
|
connectionInputData?: INodeExecutionData[],
|
||||||
itemIndex?: number,
|
itemIndex?: number,
|
||||||
): Promise<T> {
|
): 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
|
// Get the NodeType as it has the information if the credentials are required
|
||||||
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
||||||
if (nodeType === undefined) {
|
if (nodeType === undefined) {
|
||||||
|
|
|
@ -9,7 +9,9 @@ import type {
|
||||||
JsonObject,
|
JsonObject,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import { NodeApiError } 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) => {
|
export const removeTrailingSlash = (url: string) => {
|
||||||
if (url.endsWith('/')) {
|
if (url.endsWith('/')) {
|
||||||
|
@ -28,13 +30,9 @@ export async function strapiApiRequest(
|
||||||
headers: IDataObject = {},
|
headers: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const authenticationMethod = this.getNodeParameter('authentication', 0);
|
const authenticationMethod = this.getNodeParameter('authentication', 0);
|
||||||
let credentials: Pick<StrapiApiCredential, 'apiVersion' | 'url'>;
|
const credentials = await this.getCredentials(
|
||||||
|
authenticationMethod === 'password' ? StrapiApi : StrapiTokenApi,
|
||||||
if (authenticationMethod === 'password') {
|
);
|
||||||
credentials = await this.getCredentials('strapiApi');
|
|
||||||
} else {
|
|
||||||
credentials = await this.getCredentials('strapiTokenApi');
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = removeTrailingSlash(credentials.url);
|
const url = removeTrailingSlash(credentials.url);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue