mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(HTTP Request Node): Add pagination support (#5993)
Is still WIP and does not implement the correct UI yet. Github issue / Community forum post (link here to close automatically): https://community.n8n.io/t/pagination-included-into-http-node/15080 https://community.n8n.io/t/how-to-paginate-through-data-in-http-requests/28103
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
workflowToTests,
|
||||
getWorkflowFilenames,
|
||||
} from '@test/nodes/Helpers';
|
||||
import { parse as parseUrl } from 'url';
|
||||
|
||||
describe('Test HTTP Request Node', () => {
|
||||
const workflows = getWorkflowFilenames(__dirname);
|
||||
@@ -117,6 +118,48 @@ describe('Test HTTP Request Node', () => {
|
||||
isDeleted: true,
|
||||
deletedOn: '2023-02-09T05:37:31.720Z',
|
||||
});
|
||||
|
||||
// Pagination - Data not identical to dummyjson.com
|
||||
nock(baseUrl)
|
||||
.persist()
|
||||
.get('/users')
|
||||
.query(true)
|
||||
.reply(function (uri) {
|
||||
const data = parseUrl(uri, true);
|
||||
const skip = parseInt((data.query.skip as string) || '0', 10);
|
||||
const limit = parseInt((data.query.limit as string) || '10', 10);
|
||||
const nextUrl = `${baseUrl}/users?skip=${skip + limit}&limit=${limit}`;
|
||||
|
||||
const response = [];
|
||||
for (let i = skip; i < skip + limit; i++) {
|
||||
if (i > 14) {
|
||||
break;
|
||||
}
|
||||
response.push({
|
||||
id: i,
|
||||
});
|
||||
}
|
||||
|
||||
if (!response.length) {
|
||||
return [
|
||||
404,
|
||||
response,
|
||||
{
|
||||
'next-url': nextUrl,
|
||||
'content-type': this.req.headers['content-type'] || 'application/json',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
200,
|
||||
response,
|
||||
{
|
||||
'next-url': nextUrl,
|
||||
'content-type': this.req.headers['content-type'] || 'application/json',
|
||||
},
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user