2
0

🐛 Fix http req body type issue

This commit is contained in:
Baptiste Arnaud
2024-07-11 11:49:19 +02:00
parent c5794a0461
commit d838c2c816

View File

@ -197,13 +197,11 @@ export const executeWebhook = async (
if (isFormData && isJson) body = parseFormDataBody(body as object)
const request = {
const baseRequest = {
url,
method,
headers: headers ?? {},
...(basicAuth ?? {}),
json: !isFormData && body && isJson ? body : undefined,
body: body && (isFormData || !isJson) ? body : undefined,
timeout: isNotDefined(env.CHAT_API_TIMEOUT)
? false
: params.timeout && params.timeout !== defaultTimeout
@ -211,7 +209,13 @@ export const executeWebhook = async (
: isLongRequest
? maxTimeout * 1000
: defaultTimeout * 1000,
} satisfies Options & { url: string; body: any }
} satisfies Options & { url: string }
const request = body
? !isFormData && isJson
? { ...baseRequest, json: body }
: { ...baseRequest, body }
: baseRequest
try {
const response = await ky(request.url, omit(request, 'url'))