first commit

This commit is contained in:
2026-08-13 18:36:31 +09:00
commit cee36bf12d
48 changed files with 4212 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
export async function apiRequest(path, options = {}) {
const response = await fetch(path, {
...options,
credentials: 'same-origin',
headers: {
...(options.body ? { 'content-type': 'application/json' } : {}),
...options.headers,
},
});
if (response.status === 401) {
window.location.assign('/login');
throw new Error('로그인이 필요합니다.');
}
if (response.status === 204) return null;
const data = await response.json().catch(() => ({}));
if (!response.ok) throw new Error(data.error?.message ?? '요청을 처리하지 못했습니다.');
return data;
}