코드 정리

This commit is contained in:
현성필
2025-01-31 11:10:11 +09:00
parent c2d7d852d4
commit c7b6e29607
39 changed files with 1403 additions and 255 deletions
@@ -52,6 +52,53 @@ export const apiRequestService = (contextPath = '/') => {
if (!response.ok) throw new Error('Failed to delete API request');
return true;
},
async getMockRoutes(params = { name: '', page: 0 }) {
const searchParams = new URLSearchParams();
if (params.name) searchParams.append('name', params.name);
if (typeof params.page !== 'undefined') searchParams.append('page', params.page.toString());
const queryString = searchParams.toString();
const url = `${contextPath}api/mock-routes${queryString ? `?${queryString}` : ''}`;
const response = await fetch(url, { headers });
if (!response.ok) throw new Error('Failed to fetch mock routes');
return response.json();
},
async deleteMockRoutes(ids) {
const response = await fetch(`${contextPath}api/mock-routes/delete`, {
method: 'POST',
headers,
body: JSON.stringify(ids)
});
if (!response.ok) throw new Error('Failed to delete mock routes');
return true;
},
async createMockRoute(mockRoute) {
const response = await fetch(`${contextPath}api/mock-routes`, {
method: 'POST',
headers,
body: JSON.stringify(mockRoute)
});
if (!response.ok) throw new Error('Failed to create mock route');
return response.json();
},
async updateMockRoute(mockRoute) {
const response = await fetch(`${contextPath}api/mock-routes/update/${mockRoute.id}`, {
method: 'POST',
headers,
body: JSON.stringify(mockRoute)
});
if (!response.ok) throw new Error('Failed to update mock route');
return response.json();
}
};
};