Created
August 11, 2019 23:51
-
-
Save CelesteComet/bf3807f0f971263b83385a821afbf7ae to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<title></title> | |
<script type="text/javascript"> | |
INTRO_TO_ALGS = 9789650603533; | |
document.addEventListener('DOMContentLoaded', function() { | |
let form = document.querySelector('form'); | |
form.onsubmit = function(e) { | |
e.preventDefault(); | |
console.log(e); | |
} | |
}); | |
// function renderToHTML(title) { | |
// console.log(title); | |
// let img = document.createElement('img'); | |
// img.src = title; | |
// document.body.append(img); | |
// } | |
function fetchrequest(e) { | |
e.preventdefault(); | |
let input = document.queryselector('input'); | |
let isbnnumber = input.value; | |
fetch(`https://openlibrary.org/api/books?bibkeys=isbn:0385472579,lccn:62019420&format=json&jscmd=data`) | |
.then(function(response) { | |
let responsepromise = response.json(); | |
responsepromise | |
.then(function(data) { | |
console.log(data); | |
console.log("got some shit"); | |
rendertohtml(data['ISBN:' + isbnnumber].thumbnail_url); | |
}) | |
.catch(function(e) { | |
console.log(e); | |
}) | |
}) | |
} | |
</script> | |
</head> | |
<body> | |
<div> | |
<form onsubmit="fetchRequest(event)"> | |
<input type="text" name="isbn" /> | |
<button>CLICK THIS</button> | |
</form> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment