2
0

🚸 (http) Allow for query params list

Closes #1638
This commit is contained in:
Baptiste Arnaud
2024-07-15 15:28:57 +02:00
parent 94ed5724d8
commit 8e15472e82

View File

@ -142,7 +142,8 @@ export const parseWebhookAttributes = async ({
typebot.variables typebot.variables
) as ExecutableHttpRequest['headers'] | undefined ) as ExecutableHttpRequest['headers'] | undefined
const queryParams = stringify( const queryParams = stringify(
convertKeyValueTableToObject(webhook.queryParams, typebot.variables) convertKeyValueTableToObject(webhook.queryParams, typebot.variables, true),
{ indices: false }
) )
const bodyContent = await getBodyContent({ const bodyContent = await getBodyContent({
body: webhook.body, body: webhook.body,
@ -325,17 +326,19 @@ const getBodyContent = async ({
export const convertKeyValueTableToObject = ( export const convertKeyValueTableToObject = (
keyValues: KeyValue[] | undefined, keyValues: KeyValue[] | undefined,
variables: Variable[] variables: Variable[],
concatDuplicateInArray = false
) => { ) => {
if (!keyValues) return if (!keyValues) return
return keyValues.reduce((object, item) => { return keyValues.reduce<Record<string, string | string[]>>((object, item) => {
const key = parseVariables(variables)(item.key) const key = parseVariables(variables)(item.key)
const value = parseVariables(variables)(item.value) const value = parseVariables(variables)(item.value)
if (isEmpty(key) || isEmpty(value)) return object if (isEmpty(key) || isEmpty(value)) return object
return { if (object[key] && concatDuplicateInArray) {
...object, if (Array.isArray(object[key])) object[key].push(value)
[key]: value, else object[key] = [object[key], value]
} } else object[key] = value
return object
}, {}) }, {})
} }