Skip to content

Commit

Permalink
🐛 Fix http req body type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jul 11, 2024
1 parent c5794a0 commit d838c2c
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,25 @@ 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
? Math.min(params.timeout, maxTimeout) * 1000
: 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'))
Expand Down

0 comments on commit d838c2c

Please sign in to comment.