Add "Split Into Items" option to HTTP Request node (#1912)

* Added the option to flatten output so we can more easily work with arrays

*  Change parameter name

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Omar Ajoue 2021-06-23 12:04:50 +02:00 committed by GitHub
parent d3a1d3ffef
commit 427f25d3d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -347,6 +347,20 @@ export class HttpRequest implements INodeType {
placeholder: 'http://myproxy:3128',
description: 'HTTP proxy to use.',
},
{
displayName: 'Split Into Items',
name: 'splitIntoItems',
type: 'boolean',
default: false,
description: 'Outputs each element of an array as own item.',
displayOptions: {
show: {
'/responseFormat': [
'json',
],
},
},
},
{
displayName: 'Timeout',
name: 'timeout',
@ -1005,7 +1019,11 @@ export class HttpRequest implements INodeType {
}
}
returnItems.push({ json: response });
if (options.splitIntoItems === true && Array.isArray(response)) {
response.forEach(item => returnItems.push({ json: item }));
} else {
returnItems.push({ json: response });
}
}
}
}