1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-11-01 15:55:36 +01:00
site/_src/_assets/javascripts/bigchain/github.js
Matthias Kretschmann f3307082d1 Get GitHub data from microservice (#118)
* grab data from github-projects microservice bigchaindb/github-projects
* complete rewrite to get everything via Fetch API 🎉, polyfilled with github/fetch
* nicer experience for loading state
* style tweaks for hero community bar
2017-05-10 00:10:27 +02:00

35 lines
929 B
JavaScript

//include whatwg-fetch/fetch.js
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
document.getElementById('stars').innerText = stars
document.getElementById('stars').style.opacity = 1
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)
})
})