+server.js 778 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
      .filter(d => d.entidad !== 0)
      .map(d => ({
        entidad: d.entidad,
        desc_entidad: d.desc_entidad,
        sigla_entidad: d.sigla_entidad || '',
        gestiones: d.gestiones || ''
      }));
    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' }
    });
  }
}