hecho crud de permisos

This commit is contained in:
fede committed 2026-05-11 22:43:45 -03:00
1 parent 0370a958b4
commit 4062a0232f
8 files changed
+369 -1

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
import type { Permiso } from '../../types';
import { API_URL } from '../env';
import { getToken } from './token';
async function handleResponse<T>(response: Response): Promise<T> {
if (!response.ok) {
const error = await response.json().catch(() => ({ message: 'Error desconocido' }));
throw new Error(error.message || 'Error en la petición');
}
return response.json();
}
export async function obtenerPermisos(): Promise<Permiso[]> {
const response = await fetch(`${API_URL}/permisos`, {
headers: { Authorization: `Bearer ${getToken()}` }
});
return handleResponse<Permiso[]>(response);
}