🐛 Fix http req body type issue
This commit is contained in:
@@ -197,13 +197,11 @@ export const executeWebhook = async (
|
|||||||
|
|
||||||
if (isFormData && isJson) body = parseFormDataBody(body as object)
|
if (isFormData && isJson) body = parseFormDataBody(body as object)
|
||||||
|
|
||||||
const request = {
|
const baseRequest = {
|
||||||
url,
|
url,
|
||||||
method,
|
method,
|
||||||
headers: headers ?? {},
|
headers: headers ?? {},
|
||||||
...(basicAuth ?? {}),
|
...(basicAuth ?? {}),
|
||||||
json: !isFormData && body && isJson ? body : undefined,
|
|
||||||
body: body && (isFormData || !isJson) ? body : undefined,
|
|
||||||
timeout: isNotDefined(env.CHAT_API_TIMEOUT)
|
timeout: isNotDefined(env.CHAT_API_TIMEOUT)
|
||||||
? false
|
? false
|
||||||
: params.timeout && params.timeout !== defaultTimeout
|
: params.timeout && params.timeout !== defaultTimeout
|
||||||
@@ -211,7 +209,13 @@ export const executeWebhook = async (
|
|||||||
: isLongRequest
|
: isLongRequest
|
||||||
? maxTimeout * 1000
|
? maxTimeout * 1000
|
||||||
: defaultTimeout * 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 {
|
try {
|
||||||
const response = await ky(request.url, omit(request, 'url'))
|
const response = await ky(request.url, omit(request, 'url'))
|
||||||
|
|||||||
Reference in New Issue
Block a user