코드 정리
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user