Skip to content

Instantly share code, notes, and snippets.

@libasoles
Created May 1, 2018 01:39
Show Gist options
  • Save libasoles/0029123e4e459e25fc1dff93d5343901 to your computer and use it in GitHub Desktop.
Save libasoles/0029123e4e459e25fc1dff93d5343901 to your computer and use it in GitHub Desktop.
Consulta de balances en cryptomkt usando api interna
const cryptoapi = (()=>{
function getBalance(currency = 'ARS') {
return window.balances.find(x=> x.currency_name === currency)
}
function getAvailableBalance(currency = 'ARS') {
return parseFloat(getBalance(currency).disponible).toFixed(2);
}
return {
getBalance: getBalance,
getAvailableBalance: getAvailableBalance
}
})()
const balanceARS = cryptoapi.getBalance('ARS')
console.log(balanceARS.disponible)
const balanceXLM = cryptoapi.getAvailableBalance('XLM')
console.log(balanceXLM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment