Skip to content

Instantly share code, notes, and snippets.

@JackHowa
Created May 14, 2018 04:08
Show Gist options
  • Save JackHowa/e2ec378f59c4e429a3dba5a622efc8ea to your computer and use it in GitHub Desktop.
Save JackHowa/e2ec378f59c4e429a3dba5a622efc8ea to your computer and use it in GitHub Desktop.
BlandLooseMinimalsystem created by JackHowa - https://repl.it/@JackHowa/BlandLooseMinimalsystem
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