Skip to content

Instantly share code, notes, and snippets.

@malwoodsantoro
Created May 22, 2022 01:14
Show Gist options
  • Save malwoodsantoro/f929641dd8788b9f4060a7e37e7ff0aa to your computer and use it in GitHub Desktop.
Save malwoodsantoro/f929641dd8788b9f4060a7e37e7ff0aa to your computer and use it in GitHub Desktop.
dog-async-await.html
<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