부모
c3beb65942
커밋
86f0942194
@ -26,6 +26,16 @@ async function putJson<T>(url: string, body?: unknown): Promise<T> {
|
|||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function patchJson<T>(url: string, body?: unknown): Promise<T> {
|
||||||
|
const res = await fetch(url, {
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: body ? JSON.stringify(body) : undefined,
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error(`API Error: ${res.status} ${res.statusText}`);
|
||||||
|
return res.json();
|
||||||
|
}
|
||||||
|
|
||||||
async function deleteJson<T>(url: string): Promise<T> {
|
async function deleteJson<T>(url: string): Promise<T> {
|
||||||
const res = await fetch(url, { method: 'DELETE' });
|
const res = await fetch(url, { method: 'DELETE' });
|
||||||
if (!res.ok) throw new Error(`API Error: ${res.status} ${res.statusText}`);
|
if (!res.ok) throw new Error(`API Error: ${res.status} ${res.statusText}`);
|
||||||
@ -400,7 +410,7 @@ export const batchApi = {
|
|||||||
deleteJson<{ success: boolean; message: string }>(`${BASE}/schedules/${jobName}`),
|
deleteJson<{ success: boolean; message: string }>(`${BASE}/schedules/${jobName}`),
|
||||||
|
|
||||||
toggleSchedule: (jobName: string, active: boolean) =>
|
toggleSchedule: (jobName: string, active: boolean) =>
|
||||||
postJson<{ success: boolean; message: string; data?: ScheduleResponse }>(
|
patchJson<{ success: boolean; message: string; data?: ScheduleResponse }>(
|
||||||
`${BASE}/schedules/${jobName}/toggle`, { active }),
|
`${BASE}/schedules/${jobName}/toggle`, { active }),
|
||||||
|
|
||||||
// Timeline
|
// Timeline
|
||||||
|
|||||||
불러오는 중...
Reference in New Issue
Block a user