Skip to content

Instantly share code, notes, and snippets.

@nallenanderson
Last active July 21, 2016 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nallenanderson/4dd5090f9cd2edc49d6ee93a5eab2271 to your computer and use it in GitHub Desktop.
Save nallenanderson/4dd5090f9cd2edc49d6ee93a5eab2271 to your computer and use it in GitHub Desktop.
// 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