+server.js 689 Bytes
const API_BASE = 'http://136.112.29.74/api/entidad/clasificador';

export async function GET() {
  try {
    const res = await fetch(API_BASE);
    if (!res.ok) throw new Error();
    const data = await res.json();
    // Mapear al formato que espera el treemap
    const mapped = data.map(d => ({
      entidad: d.entidad,
      desc_entidad: d.desc_entidad,
      sigla_entidad: d.sigla_entidad || ''
    }));
    return new Response(JSON.stringify(mapped), {
      headers: { 'Content-Type': 'application/json' }
    });
  } catch {
    return new Response(JSON.stringify({ error: 'Failed to fetch' }), {
      status: 500, headers: { 'Content-Type': 'application/json' }
    });
  }
}