Created
July 22, 2019 23:42
-
-
Save matthewsimo/a53c769fdc6dccfac3daaba980817a91 to your computer and use it in GitHub Desktop.
Help for Jed
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
// Fetch the book data | |
var books = fetch('http://someaweomseapi.com/api') | |
.then(function(response){ | |
return response.json(); | |
}) | |
.then(function(json){ | |
console.log('fetch result:', json) | |
return json | |
}) | |
// Assuming json is an array here but something like this.. | |
// Loop through each book and build the mark up for each, then join them without any separator | |
var booksHtml = books.map(function(book, index){ | |
return '<li>' + index + ' - ' + book.title + '</li>'; | |
}).join(''); | |
// Inject the markup into some place in the DOM | |
var wrapper = document.querySelector('.some-unique-selector').html(booksHtml) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment