fix
This commit is contained in:
parent
fa0703340a
commit
fa787fe6af
|
@ -24,6 +24,10 @@ export function useApi<T>(
|
|||
|
||||
const execute = useCallback(
|
||||
async (...args: any[]): Promise<T | null> => {
|
||||
if (!endpoint) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
@ -42,7 +46,7 @@ export function useApi<T>(
|
|||
case 'PUT':
|
||||
response = await axios.put<T>(`${API_URL}${endpoint}`, args[0], { headers });
|
||||
break;
|
||||
case 'PATCH': // Добавляем поддержку PATCH-запросов
|
||||
case 'PATCH':
|
||||
response = await axios.patch<T>(`${API_URL}${endpoint}`, args[0], { headers });
|
||||
break;
|
||||
case 'DELETE':
|
||||
|
@ -73,7 +77,6 @@ export function useApi<T>(
|
|||
return { data, loading, error, execute };
|
||||
}
|
||||
|
||||
// Вспомогательные функции для типичных запросов
|
||||
export function useGet<T>(endpoint: string) {
|
||||
return useApi<T>(endpoint, 'GET');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue