-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
57 lines (47 loc) · 1.93 KB
/
index.html
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
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BUDGET APP</title>
</head>
<body>
<table>
<thead>
<tr>
<th>Código</th>
<th>categoria</th>
<th>balance</th>
</tr>
</thead>
<tbody id="tablaCategoria">
</tbody>
</table>
<a href="alta.html">cargar categorias</a>
<a href="depositos.html">hacer deposito</a>
<script>
const URL = "https://Sanddfort02.pythonanywhere.com/"
fetch(URL + 'listado')
.then(function (response) {
if (response.ok) {
return response.json();
} else {
throw new Error('Error al obtener los productos.');
}
})
.then(function (data) {
var tablaProductos = document.getElementById('tablaCategoria');
data.forEach(function (categoria) {
var fila = document.createElement('tr');
fila.innerHTML = '<td>' + categoria.categoria_id + '</td>' +
'<td>' + categoria.categoria + '</td>' +
'<td align="right"> ' + categoria.balance + '</td>'
tablaProductos.appendChild(fila);
});
})
.catch(function (error) {
alert('Error al obtener los productos.');
});
</script>
</body>
</html>