Created
June 15, 2020 18:11
-
-
Save lizrice/810c6aa5d609c147fd1ec6536a695b35 to your computer and use it in GitHub Desktop.
Stargazer count
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | |
</head> | |
<body> | |
<p>Project <span id="repo">aquasecurity/trivy</span> <span id="starcount"></span></p> | |
</body> | |
<script> | |
function getStarcount(repo, resultElement) { | |
var url = 'https://api.github.com/repos/' + repo; | |
axios.get(url) | |
.then(function (response) { | |
resultElement.innerHTML = response.data.stargazers_count; | |
}) | |
.catch(function (error) { | |
console.log(error); | |
}); | |
} | |
function repo() { | |
var repo = document.getElementById('repo').innerHTML; | |
var starcount = document.getElementById('starcount'); | |
getStarcount(repo, starcount); | |
} | |
document.addEventListener('DOMContentLoaded', repo()); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment