javascript - Google Books API JSON object trouble -
i trying pull google books api , insert titles first 10 results web page. have site pulling correct request , have following callback function handling results
function insert(books) { var list = books.items; var i; for(i = 0; < 10; i++){ var title = list[i].title; var tag = "result" + i; var x = document.getelementbyid(tag); x.innerhtml = title; } }
for ease lets suppose following call made
<script src="https://www.googleapis.com/books/v1/volumes?q=way of kings&filter=partial&callback=insert"></script>
right inserts word "undefined" in every place should insert title. can't find error here.
the response data has title
placed in volumeinfo
object.
replace:
var title = list[i].title;
with:
var title = list[i].volumeinfo.title;
Comments
Post a Comment