Skip to content

Instantly share code, notes, and snippets.

@lizrice
Created June 15, 2020 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizrice/810c6aa5d609c147fd1ec6536a695b35 to your computer and use it in GitHub Desktop.
Save lizrice/810c6aa5d609c147fd1ec6536a695b35 to your computer and use it in GitHub Desktop.
Stargazer count
<!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