Mudança
This commit is contained in:
@@ -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
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user