Created
May 22, 2022 01:14
-
-
Save malwoodsantoro/f929641dd8788b9f4060a7e37e7ff0aa to your computer and use it in GitHub Desktop.
dog-async-await.html
This file contains hidden or 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> | |
<style> | |
* { | |
background-color: pink; | |
border-radius: 5px; | |
padding: 10px; | |
} | |
</style> | |
<script> | |
const requestAPI = async () => { | |
const response = await fetch('https://dog.ceo/api/breeds/image/random'); | |
const json = await response.json(); | |
const img = await json.message; | |
var dogHTML = ''; | |
dogHTML += '<img src="' + img + '" width="400">'; | |
document.getElementById("dog").innerHTML = dogHTML; | |
} | |
requestAPI(); | |
</script> | |
</head> | |
<body> | |
<h1>refresh 4 more dog</h1> | |
<div id="dog"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment