I've been working on retrieving data from the Google Books API and displaying the titles of the first 10 results on a web page. The site is successfully making the request, and I have a callback function that handles the results as shown below:
function displayTitles(books) {
var list = books.items;
var i;
for(i = 0; i < 10; i++) {
var title = list[i].title;
var tag = "result" + i;
var x = document.getElementById(tag);
x.innerHTML = title;
}
}
Let's assume the following API call was made:
<script src="https://www.googleapis.com/books/v1/volumes?q=Way of Kings&filter=partial&callback=displayTitles"></script>
Currently, it's displaying "undefined" instead of the actual titles in each designated location. I'm having trouble identifying the error. Can anyone help?