Skip to content

Instantly share code, notes, and snippets.

@julianeon
Created May 31, 2020 19:24
Show Gist options
  • Save julianeon/05b054b258b6875e4d6f4c3e0920e289 to your computer and use it in GitHub Desktop.
Save julianeon/05b054b258b6875e4d6f4c3e0920e289 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>JavaScript GET Request</title>
<style>
.box {
padding-left: 20vw;
padding-right: 20vw;
padding-top: 10vh;
padding-bottom: 10vh;
background: linear-gradient(#e66465, #9198e5);
}
.box > p {
font-size: x-large;
padding-top: 1vh;
padding-bottom: 1vh;
padding-left: 1vw;
border-radius: 25px;
background: linear-gradient(white 10%, 30%, blue 90%);
color: white;
}
</style>
</head>
<body>
<div class="box">
</div>
<script>
const url='https://api.domainsdb.info/v1/domains/search?domain=medium&zone=com'
const proxy = 'https://cors-anywhere.herokuapp.com/'
fetch(proxy + url)
.then(blob => blob.json())
.then(data => {
let items=[];
data.domains.map(element => items.push(element.domain));
const lines=data.domains.map((element) => "<p>"+ element.domain + "</p>");
document.querySelector(".box").innerHTML = lines.join('');
})
.catch(e => {
console.log(e);
return e;
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment