mr feedback

This commit is contained in:
Jorrin 2024-01-25 19:37:15 +01:00
parent ad8c6709a1
commit b5cd297ad8
1 changed files with 2 additions and 7 deletions

View File

@ -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;
} }