diff --git a/src/hooks/useApi.ts b/src/hooks/useApi.ts index b4a8b8d..e0ae8a3 100644 --- a/src/hooks/useApi.ts +++ b/src/hooks/useApi.ts @@ -24,6 +24,10 @@ export function useApi( const execute = useCallback( async (...args: any[]): Promise => { + if (!endpoint) { + return null; + } + try { setLoading(true); setError(null); @@ -42,7 +46,7 @@ export function useApi( case 'PUT': response = await axios.put(`${API_URL}${endpoint}`, args[0], { headers }); break; - case 'PATCH': // Добавляем поддержку PATCH-запросов + case 'PATCH': response = await axios.patch(`${API_URL}${endpoint}`, args[0], { headers }); break; case 'DELETE': @@ -73,7 +77,6 @@ export function useApi( return { data, loading, error, execute }; } -// Вспомогательные функции для типичных запросов export function useGet(endpoint: string) { return useApi(endpoint, 'GET'); }