historico.js
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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: {
'Accept': 'application/json',
"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'));
});
}