-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbooks.js
More file actions
34 lines (27 loc) · 1.05 KB
/
books.js
File metadata and controls
34 lines (27 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$(document).ready(function() {
function getBooks() {
let search = document.getElementById("search").value;
var apply = document.getElementById("apply");
console.log(search);
const apiKey = "AIzaSyAPhGOrnFvJb8JfYysnrGrAH9wYppYy-V4";
$.ajax({
url:
"https://www.googleapis.com/books/v1/volumes?q="+
search+
"&key="+
apiKey,
dataType: "json",
success: function (book) {
console.log(book);
for(var i = 0; i < book.items.length; i++) {
console.log(book.items[i].volumeInfo.title);
apply.innerHTML += "<h3>" + book.items[i].volumeInfo.title + "<h3>";
apply.innerHTML += "<img src='" + book.items[i].volumeInfo.imageLinks.thumbnail + "'>";
}
},
type: "GET"
});
}
var submitButton = document.querySelector('#submit');
submitButton.addEventListener('click', getBooks, false);
});