Add BCH to bitpay.js

This commit is contained in:
Neal Conner 2017-12-15 19:29:55 -05:00 committed by Josh Harvey
parent d20104249f
commit e232a7713e

View file

@ -2,11 +2,11 @@ const axios = require('axios')
const BN = require('../../../bn') const BN = require('../../../bn')
function ticker (account, fiatCode, cryptoCode) { function ticker (account, fiatCode, cryptoCode) {
if (cryptoCode !== 'BTC') { if (!_.includes(cryptoCode, ['BTC', 'BCH'])) {
return Promise.reject('Unsupported crypto: ' + cryptoCode) return Promise.reject('Unsupported crypto: ' + cryptoCode)
} }
return axios.get('https://bitpay.com/api/rates/' + fiatCode) return axios.get('https://bitpay.com/api/rates/' + cryptoCode '/' + fiatCode)
.then(r => { .then(r => {
const data = r.data const data = r.data
const price = BN(data.rate) const price = BN(data.rate)