-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.html
55 lines (52 loc) · 1.63 KB
/
backend.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
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Consumidor de API com Tabela Bootstrap</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script>
async function fetchApiData() {
const apiUrl = 'https://api.invertexto.com/v1/faker?token=6425|at4CHIcGEXPa2vbKVMksg84sWP7cr2qp&locale=pt_BR';
let tableContent = '';
for (let i = 0; i < 5; i++) {
const response = await fetch(apiUrl);
const data = await response.json();
tableContent += `
<tr>
<td>${data.uuid}</td>
<td>${data.name}</td>
<td>${data.cpf}</td>
<td>${data.birth_date}</td>
<td>${data.email}</td>
</tr>
`;
}
document.getElementById('apiTableBody').innerHTML = tableContent;
}
</script>
</head>
<body>
<div class="container mt-5">
<h1>Consumidor de API com Tabela Bootstrap</h1>
<button class="btn btn-primary" onclick="fetchApiData()">Gerar Tabela</button>
<table class="table mt-3">
<thead class="thead-dark">
<tr>
<th>UUID</th>
<th>Nome</th>
<th>CPF</th>
<th>Data de Nasc.</th>
<th>Email</th>
</tr>
</thead>
<tbody id="apiTableBody">
<!-- Os dados da API serão inseridos aqui -->
</tbody>
</table>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</body>
</html>