import type { Usuario } from '../../types'; import { API_URL } from '../env'; import { getToken } from './token'; async function handleResponse(response: Response): Promise { 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 obtenerUsuarioPorId(id: number): Promise { const response = await fetch(`${API_URL}/usuario/${id}`, { headers: { Authorization: `Bearer ${getToken()}` } }); return handleResponse(response); }