|
|
@ -8,7 +8,7 @@ class CurrencyController { |
|
|
|
|
|
|
|
|
|
|
|
constructor (opts = {}) { |
|
|
|
constructor (opts = {}) { |
|
|
|
const initState = extend({ |
|
|
|
const initState = extend({ |
|
|
|
currentCurrency: 'ethusd', |
|
|
|
currentCurrency: 'usd', |
|
|
|
conversionRate: 0, |
|
|
|
conversionRate: 0, |
|
|
|
conversionDate: 'N/A', |
|
|
|
conversionDate: 'N/A', |
|
|
|
}, opts.initState) |
|
|
|
}, opts.initState) |
|
|
@ -45,7 +45,7 @@ class CurrencyController { |
|
|
|
|
|
|
|
|
|
|
|
updateConversionRate () { |
|
|
|
updateConversionRate () { |
|
|
|
const currentCurrency = this.getCurrentCurrency() |
|
|
|
const currentCurrency = this.getCurrentCurrency() |
|
|
|
return fetch(`https://api.infura.io/v1/ticker/${currentCurrency}`) |
|
|
|
return fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency}`) |
|
|
|
.then(response => response.json()) |
|
|
|
.then(response => response.json()) |
|
|
|
.then((parsedResponse) => { |
|
|
|
.then((parsedResponse) => { |
|
|
|
this.setConversionRate(Number(parsedResponse.bid)) |
|
|
|
this.setConversionRate(Number(parsedResponse.bid)) |
|
|
|