-
Notifications
You must be signed in to change notification settings - Fork 0
/
testemostrarclientes.html
37 lines (34 loc) · 1.06 KB
/
testemostrarclientes.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button onclick="load(display)">Mostrar clientes</button>
<div>
<p id="mostrar"></p>
</div>
<script>
function load(callback){
fetch("http://localhost:3000/clientes")
.then (x => x.json())
.then (y => display(y))
callback()
}
function display(dados){
var clientes = []
clientes = dados
console.log(clientes)
var paragrafo = ""
for(let i = 0 ; i<clientes.length ; i++){
paragrafo +=`<p>${clientes[i].nome}</p>
<p>${clientes[i].email}</p>
<p>${clientes[i].fone}</p>`
}
document.getElementById("mostrar").innerHTML = paragrafo
}
</script>
</body>
</html>