diff --git a/apirest/frontend/script.js b/apirest/frontend/script.js index 92377bb..9e1ebfc 100644 --- a/apirest/frontend/script.js +++ b/apirest/frontend/script.js @@ -4,17 +4,18 @@ async function carregarProdutos(){ throw new Error("Não foi possível carregar a lista") } const produtos = await resposta.join(); - - let tbody = document.querySelector("tbody"); - + let tbody = document.querySelector("tbody"); produtos.forEach(produto =>{ let linha = document.createElement("tr") linha.innerHTML = ` ${produto.nome} ${produto.preco} ${produto.estoque} - ` - - tbody.appendChild - }) -} \ No newline at end of file + ` + tbody.appendChild(linha); + }); +} + +window.addEventListener("load", () => { + carregarProdutos(); +}) \ No newline at end of file