| 991 | } |
| 992 | |
| 993 | function appendQuery(params: URLSearchParams, key: string, value: unknown): void { |
| 994 | if (value === undefined || value === null) return |
| 995 | if (Array.isArray(value)) { |
| 996 | for (const item of value) appendQuery(params, key, item) |
| 997 | return |
| 998 | } |
| 999 | if (typeof value === "object") { |
| 1000 | for (const [child, item] of Object.entries(value)) appendQuery(params, `${key}[${child}]`, item) |
| 1001 | return |
| 1002 | } |
| 1003 | params.append(key, String(value)) |
| 1004 | } |
| 1005 | |
| 1006 | async function json(response: Response): Promise<unknown> { |
| 1007 | if (!isContentType(response, "application/json") && !response.headers.get("content-type")?.includes("+json")) { |