This commit is contained in:
seb
2026-09-18 07:37:25 +02:00
parent a537c2f72d
commit dd13f736c0
5 changed files with 75 additions and 6 deletions

View File

@@ -20,7 +20,11 @@ function readableHeaders(headers) {
}
async function http(path, { method = 'GET', body } = {}) {
const headers = { 'Content-Type': 'application/json' };
const isFormData = typeof FormData !== 'undefined' && body instanceof FormData;
const headers = {};
if (!isFormData) {
headers['Content-Type'] = 'application/json';
}
const url = new URL(path, window.location.origin).href;
logApi('request', {
@@ -38,7 +42,7 @@ async function http(path, { method = 'GET', body } = {}) {
method,
headers,
credentials: 'include',
body: body ? JSON.stringify(body) : undefined,
body: isFormData ? body : (body ? JSON.stringify(body) : undefined),
});
const responseHeaders = readableHeaders(res.headers);