mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
⚡ 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:
parent
d3a1d3ffef
commit
427f25d3d0
|
@ -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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue