-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adição dos livros á página de categorias por chamada de API
- Loading branch information
1 parent
0dd6ebb
commit fa218b6
Showing
3 changed files
with
33 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
let livros = []; | ||
const endpointDaApi = 'https://guilhermeonrails.github.io/casadocodigo/livros.json'; | ||
getBuscarLivrosDaApi(); | ||
|
||
const elementoParaInserirLivros = document.getElementById('livros'); | ||
|
||
async function getBuscarLivrosDaApi() { | ||
const res = await fetch(endpointDaApi); | ||
livros = await res.json(); | ||
console.table(livros); | ||
exibirOsLivrosNaTela(livros); | ||
} | ||
|
||
function exibirOsLivrosNaTela(listaDeLivros){ | ||
listaDeLivros.forEach(livro => { | ||
elementoParaInserirLivros.innerHTML += ` | ||
<div class="livro"> | ||
<img class="livro__imagens" src="${livro.imagem}" alt="${livro.alt}" /> | ||
<h2 class="livro__titulo"> | ||
${livro.titulo} | ||
</h2> | ||
<p class="livro__descricao">${livro.autor}</p> | ||
<p class="livro__preco" id="preco">R$ ${livro.preco}</p> | ||
<div class="tags"> | ||
<span class="tag">${livro.categoria}</span> | ||
</div> | ||
</div> | ||
`; | ||
}) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fa218b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
alurabooks – ./
alurabooks-wells.vercel.app
alurabooks-git-main-wellingtonfernandes.vercel.app
alurabooks-wellingtonfernandes.vercel.app