From fa787fe6af371d2f32becd17f13bb427dcea5ba2 Mon Sep 17 00:00:00 2001 From: itqop Date: Tue, 11 Feb 2025 13:05:07 +0300 Subject: [PATCH] fix --- src/hooks/useApi.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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'); }