Created
May 14, 2018 04:08
-
-
Save JackHowa/e2ec378f59c4e429a3dba5a622efc8ea to your computer and use it in GitHub Desktop.
BlandLooseMinimalsystem created by JackHowa - https://repl.it/@JackHowa/BlandLooseMinimalsystem
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
const axios = require('axios'); | |
const baseURL = 'https://rest.coinapi.io'; | |
const apiKey = 'X'; | |
const bitcoinPath = '/v1/exchangerate/BTC'; | |
getDetails(); | |
async function getDetails() { | |
let bitcoinPromise = axios.get( | |
'https://rest.coinapi.io/v1/exchangerate/BTC?apikey=' + apiKey | |
); | |
let [bitcoinPrice] = await Promise.all([bitcoinPromise]); | |
let bitcoinPrices = bitcoinPrice.data.rates; | |
let targetPrice = bitcoinPrices.find( | |
bitcoinPriceObject => bitcoinPriceObject.asset_id_quote === 'USD' | |
); | |
console.log(targetPrice); | |
} | |
// findUSD(); | |
function findUSD() { | |
let bitcoinPrices = [ | |
{ | |
time: '2018-05-14T03:42:29.6109862Z', | |
asset_id_quote: 'ETH', | |
rate: 11.992371654885664 | |
}, | |
{ | |
time: '2018-05-14T03:42:29.6109862Z', | |
asset_id_quote: 'EUR' | |
} | |
]; | |
let targetKey = 'asset_id_quote'; | |
let targetValue = 'USD'; | |
let targetPrice = bitcoinPrices.find( | |
priceObject => priceObject.asset_id_quote === 'EUR' | |
); | |
console.log(targetPrice); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment