Last active
December 23, 2017 21:31
-
-
Save ognjengt/d1a07bda77642d7c8ab51ab658fbf6a0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function refreshBitcoinPrices() { | |
const request = async () => { | |
var results = await fetch("https://blockchain.info/ticker"); | |
results = await results.json(); | |
bitcoinData.results = results; | |
if(bitcoinData.results) {console.log('Blockchain API works!');} | |
else console.log('Blockchain API is down at the moment.'); | |
// Get todays date | |
this.todayDate = new Date(); | |
this.todayDate = this.todayDate.toISOString().split('T')[0]; | |
console.log(this.todayDate); | |
console.log('New prices fetched.'); | |
console.log('Most recent bitcoin price: '+bitcoinData.results.USD.last); | |
console.log('Time: '+new Date().getHours()+':'+new Date().getMinutes()); | |
} | |
request(); | |
// Enable in prod | |
setInterval(() => { | |
request(); | |
},COIN_FETCH_TIMEOUT); // 1000*60*118 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment