Skip to content

Commit

Permalink
⚡ strapiApiRequestAllItems fix
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency committed Aug 31, 2023
1 parent 43b0804 commit 18f6afd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Strapi/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
9 changes: 5 additions & 4 deletions packages/nodes-base/nodes/Strapi/Strapi.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
INodeExecutionData,
INodeType,
INodeTypeDescription,
CredentialInformation,
} from 'n8n-workflow';
import { NodeOperationError } from 'n8n-workflow';

Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -252,6 +251,7 @@ export class Strapi implements INodeType {
{},
qs,
headers,
apiVersion,
);
} else {
qs['pagination[pageSize]'] = this.getNodeParameter('limit', i);
Expand Down Expand Up @@ -295,6 +295,7 @@ export class Strapi implements INodeType {
{},
qs,
headers,
apiVersion,
);
} else {
qs._limit = this.getNodeParameter('limit', i);
Expand Down

0 comments on commit 18f6afd

Please sign in to comment.