mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
feat(HTTP Request Node): Interval Between Requests option for pagination (#8224)
## Summary Option to add delay between request when using pagination  ## Related tickets and issues https://linear.app/n8n/issue/NODE-1029/http-request-pagination-feature-doesnt-use-batch-settings https://github.com/n8n-io/n8n/issues/8062
This commit is contained in:
parent
b50d8058cf
commit
270328ccf6
|
@ -115,6 +115,7 @@ import {
|
||||||
ExecutionBaseError,
|
ExecutionBaseError,
|
||||||
jsonParse,
|
jsonParse,
|
||||||
ApplicationError,
|
ApplicationError,
|
||||||
|
sleep,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import type { Token } from 'oauth-1.0a';
|
import type { Token } from 'oauth-1.0a';
|
||||||
import clientOAuth1 from 'oauth-1.0a';
|
import clientOAuth1 from 'oauth-1.0a';
|
||||||
|
@ -2748,6 +2749,9 @@ const getRequestHelperFunctions = (
|
||||||
) as boolean;
|
) as boolean;
|
||||||
|
|
||||||
if (makeAdditionalRequest) {
|
if (makeAdditionalRequest) {
|
||||||
|
if (paginationOptions.requestInterval) {
|
||||||
|
await sleep(paginationOptions.requestInterval);
|
||||||
|
}
|
||||||
if (tempResponseData.statusCode < 200 || tempResponseData.statusCode >= 300) {
|
if (tempResponseData.statusCode < 200 || tempResponseData.statusCode >= 300) {
|
||||||
// We have it configured to let all requests pass no matter the response code
|
// We have it configured to let all requests pass no matter the response code
|
||||||
// via "requestOptions.simple = false" to not by default fail if it is for example
|
// via "requestOptions.simple = false" to not by default fail if it is for example
|
||||||
|
|
|
@ -1143,6 +1143,23 @@ export class HttpRequestV3 implements INodeType {
|
||||||
default: 100,
|
default: 100,
|
||||||
description: 'Maximum amount of request to be make',
|
description: 'Maximum amount of request to be make',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
|
||||||
|
displayName: 'Interval Between Requests (ms)',
|
||||||
|
name: 'requestInterval',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
hide: {
|
||||||
|
paginationMode: ['off'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: 0,
|
||||||
|
description: 'Time in milliseconds to wait between requests',
|
||||||
|
hint: 'At 0 no delay will be added',
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -1272,6 +1289,7 @@ export class HttpRequestV3 implements INodeType {
|
||||||
completeExpression: string;
|
completeExpression: string;
|
||||||
limitPagesFetched: boolean;
|
limitPagesFetched: boolean;
|
||||||
maxRequests: number;
|
maxRequests: number;
|
||||||
|
requestInterval: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||||
|
@ -1653,6 +1671,7 @@ export class HttpRequestV3 implements INodeType {
|
||||||
const paginationData: PaginationOptions = {
|
const paginationData: PaginationOptions = {
|
||||||
continue: continueExpression,
|
continue: continueExpression,
|
||||||
request: {},
|
request: {},
|
||||||
|
requestInterval: pagination.requestInterval,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pagination.paginationMode === 'updateAParameterInEachRequest') {
|
if (pagination.paginationMode === 'updateAParameterInEachRequest') {
|
||||||
|
|
|
@ -526,6 +526,7 @@ export interface PaginationOptions {
|
||||||
binaryResult?: boolean;
|
binaryResult?: boolean;
|
||||||
continue: boolean | string;
|
continue: boolean | string;
|
||||||
request: IRequestOptionsSimplifiedAuth;
|
request: IRequestOptionsSimplifiedAuth;
|
||||||
|
requestInterval: number;
|
||||||
maxRequests?: number;
|
maxRequests?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue