Skip to content

Instantly share code, notes, and snippets.

@nallenanderson
Last active Jul 21, 2016
Embed
What would you like to do?
// Chain this onto the end of the AJAX request.
.then( () => {
// Create an array of <div>s and then map over each element to create a div with image and title.
const showImages = `
${jsonData.map( card => {
return `
<div class="col-md-6">
<div class="card">
<img src=${card.covers[0]} class="img-responsive" />
<div class="card-title">
<h4>${card.title}</h4>
</div>
</div>
</div>
`
}
)
// Remove any '' from the map array.
.join('')}
`;
const imagesDiv = document.querySelector('#images');
imagesDiv.innerHTML = showImages;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment