mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Add support of array in querystring (#1914)
* ⚡ Add support of array in querystring In the HTTP Request node, a parameter that appeared multiple times with the same name will be converted into an array. Any parameters that appeared only once will be kept in the form of a string for backward compatibility. * ⚡ Prefer spread operator
This commit is contained in:
parent
922880f93d
commit
800e5ec97f
|
@ -811,8 +811,23 @@ export class HttpRequest implements INodeType {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
requestOptions[optionName] = {};
|
requestOptions[optionName] = {};
|
||||||
for (const parameterData of setUiParameter!.parameter as IDataObject[]) {
|
for (const parameterData of setUiParameter!.parameter as IDataObject[]) {
|
||||||
// @ts-ignore
|
const parameterDataName = parameterData!.name as string;
|
||||||
requestOptions[optionName][parameterData!.name as string] = parameterData!.value;
|
const newValue = parameterData!.value;
|
||||||
|
if (optionName === 'qs') {
|
||||||
|
const computeNewValue = (oldValue: unknown) => {
|
||||||
|
if (typeof oldValue === 'string') {
|
||||||
|
return [oldValue, newValue];
|
||||||
|
} else if (Array.isArray(oldValue)) {
|
||||||
|
return [...oldValue, newValue];
|
||||||
|
} else {
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
requestOptions[optionName][parameterDataName] = computeNewValue(requestOptions[optionName][parameterDataName]);
|
||||||
|
} else {
|
||||||
|
// @ts-ignore
|
||||||
|
requestOptions[optionName][parameterDataName] = newValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue