con este par de cambios ya tengo que muestra los grupos

This commit is contained in:
fede committed 2026-05-11 22:43:29 -03:00
1 parent 617583def5
commit 0370a958b4
9 files changed
+98 -28

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import type { Usuario } 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 modificarUsuario(
id: number,
data: Partial<{ email: string; name: string }>
): Promise<Usuario> {
const response = await fetch(`${API_URL}/users/${id}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${getToken()}`
},
body: JSON.stringify(data)
});
return handleResponse<Usuario>(response);
}