-
Notifications
You must be signed in to change notification settings - Fork 15
/
main.js
35 lines (30 loc) · 895 Bytes
/
main.js
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
function fazGet(url) {
let request = new XMLHttpRequest()
request.open("GET", url, false)
request.send()
return request.responseText
}
function criaLinha(usuario) {
console.log(usuario)
linha = document.createElement("tr");
tdId = document.createElement("td");
tdNome = document.createElement("td");
tdId.innerHTML = usuario.id
tdNome.innerHTML = usuario.name
linha.appendChild(tdId);
linha.appendChild(tdNome);
return linha;
}
function main() {
let data = fazGet("http://127.0.0.1:5000/get/usuarios");
let usuarios = JSON.parse(data);
let tabela = document.getElementById("tabela");
usuarios.forEach(element => {
let linha = criaLinha(element);
tabela.appendChild(linha);
});
// Para cada usuario
// criar uma linha
// adicionar na tabela
}
main()