historico.js 1.31 KB
document.addEventListener('DOMContentLoaded', () => {
    const requestData = {
        "token": "sdñÑREgerqw3$E#]ÑgdfbversdfFfew435",
        "url": "https://validacion.hgtsa.com.ar/api_rto/diaria",
        "clear": true,
        "params": {
            "ApiKey": "sdñÑREgerqw3$E#]ÑgdfbversdfFfew435",
            "id_cent": "061"
        }
    };

    fetch('https://api.hgt.com.ar/redirect', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(requestData)
    })
    .then(response => response.json())
    .then(data => {
        createHistoricoList(data);
    })
    .catch(error => {
        console.error('Error:', error);
    });
});

// Function to create the list items
function createHistoricoList(data) {
    const historicoDiv = document.getElementById('div_historico');
    data.inspecciones.forEach(inspeccion => {
        const div = document.createElement('div');
        div.textContent = inspeccion.name;
        
        const button = document.createElement('button');
        button.className = 'PDFButton';
        button.id = inspeccion.name;
        button.textContent = 'ir historico';

        div.appendChild(button);
        historicoDiv.appendChild(div);
        historicoDiv.appendChild(document.createElement('br'));
    });
}