This commit is contained in:
Israel Alves de Oliveira Arruda 2026-06-01 19:28:19 -03:00
parent c3edf5a11d
commit 45f4b50233
3 changed files with 46 additions and 5 deletions

View File

@ -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>

View File

@ -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
})
}

View File

@ -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;
}