1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-12-02 05:57:18 +01:00
site/_src/_assets/javascripts/bigchain/github.js

34 lines
1005 B
JavaScript

document.addEventListener('DOMContentLoaded', function() {
const url = 'https://bigchaindb-github.now.sh'
function injectData(data) {
const repos = data
// just grab the first item of array
// should always be bigchaindb/bigchaindb cause of ordering by most stars
const repo = repos[0]
const stars = repo.stars
const release = repo.release
const releaseUrl = repo.release_url
document.getElementById('stars').innerText = stars
document.getElementById('stars').style.opacity = 1
document.getElementById('release-link').href = releaseUrl
document.getElementById('release').innerText = release
document.getElementById('release').style.opacity = 1
}
fetch(url)
.then(function(response) {
return response.json()
})
.then(function(data) {
injectData(data)
})
.catch(function(error) {
console.log(error)
})
})