Mudança
This commit is contained in:
parent
c3edf5a11d
commit
45f4b50233
|
|
@ -7,15 +7,23 @@
|
||||||
<title>Produtos</title>
|
<title>Produtos</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
|
||||||
|
|
||||||
</header>
|
|
||||||
<main>
|
|
||||||
<h1> Lista de produtos</h1>
|
<h1> Lista de produtos</h1>
|
||||||
|
<main>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Nome</th>
|
||||||
|
<th>Preço</th>
|
||||||
|
<th>Estoque</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="conteudo_tabela">
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
</main>
|
</main>
|
||||||
|
<script src=""script.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
async function carregarProdutos(){
|
||||||
|
const resposta = await fetch("http://localhost:5000/produtos");
|
||||||
|
if (!resposta.ok){
|
||||||
|
throw new Error("Não foi possível carregar a lista")
|
||||||
|
}
|
||||||
|
const produtos = await resposta.join();
|
||||||
|
|
||||||
|
let tbody = document.querySelector("tbody");
|
||||||
|
|
||||||
|
produtos.forEach(produto =>{
|
||||||
|
let linha = document.createElement("tr")
|
||||||
|
linha.innerHTML = `
|
||||||
|
<td>${produto.nome}</td>
|
||||||
|
<td>${produto.preco}</td>
|
||||||
|
<td>${produto.estoque}</td>
|
||||||
|
`
|
||||||
|
|
||||||
|
tbody.appendChild
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
* {
|
||||||
|
margin : o;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1{
|
||||||
|
width : 300px;
|
||||||
|
background-color: brown;
|
||||||
|
padding: 20px;
|
||||||
|
border: 10px solid black;
|
||||||
|
text-align: center;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue