|
|
@ -6,17 +6,12 @@ export function getBodyTypeFromBody( |
|
|
|
if (typeof body === "string") return "string"; |
|
|
|
if (typeof body === "string") return "string"; |
|
|
|
if (body instanceof FormData) return "FormData"; |
|
|
|
if (body instanceof FormData) return "FormData"; |
|
|
|
if (body instanceof URLSearchParams) return "URLSearchParams"; |
|
|
|
if (body instanceof URLSearchParams) return "URLSearchParams"; |
|
|
|
if (typeof body === "object") return "object"; |
|
|
|
return "object"; |
|
|
|
return undefined; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function convertBodyToObject(body: unknown): any { |
|
|
|
export function convertBodyToObject(body: unknown): any { |
|
|
|
if (body instanceof FormData || body instanceof URLSearchParams) { |
|
|
|
if (body instanceof FormData || body instanceof URLSearchParams) { |
|
|
|
const obj: Record<string, any> = {}; |
|
|
|
return [...body]; |
|
|
|
for (const [key, value] of body.entries()) { |
|
|
|
|
|
|
|
obj[key] = value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return obj; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return body; |
|
|
|
return body; |
|
|
|
} |
|
|
|
} |
|
|
|