aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/currency.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-04-04 01:33:10 +0800
committerkumavis <aaron@kumavis.me>2018-04-04 01:33:10 +0800
commitecbab14cae659cdcec9e59dc0a3f450069a6a05f (patch)
treef3df4bb5f9cccb9b504cba52eea8cb71f5af075f /app/scripts/controllers/currency.js
parent3e4b11e0d701441720bec665167984240a2aca56 (diff)
downloadtangerine-wallet-browser-ecbab14cae659cdcec9e59dc0a3f450069a6a05f.tar
tangerine-wallet-browser-ecbab14cae659cdcec9e59dc0a3f450069a6a05f.tar.gz
tangerine-wallet-browser-ecbab14cae659cdcec9e59dc0a3f450069a6a05f.tar.bz2
tangerine-wallet-browser-ecbab14cae659cdcec9e59dc0a3f450069a6a05f.tar.lz
tangerine-wallet-browser-ecbab14cae659cdcec9e59dc0a3f450069a6a05f.tar.xz
tangerine-wallet-browser-ecbab14cae659cdcec9e59dc0a3f450069a6a05f.tar.zst
tangerine-wallet-browser-ecbab14cae659cdcec9e59dc0a3f450069a6a05f.zip
app - warn on fetch errors instead of spamming sentry
Diffstat (limited to 'app/scripts/controllers/currency.js')
-rw-r--r--app/scripts/controllers/currency.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js
index 930fc52e8..aca57dc71 100644
--- a/app/scripts/controllers/currency.js
+++ b/app/scripts/controllers/currency.js
@@ -43,20 +43,18 @@ class CurrencyController {
this.store.updateState({ conversionDate })
}
- updateConversionRate () {
- const currentCurrency = this.getCurrentCurrency()
- return fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`)
- .then(response => response.json())
- .then((parsedResponse) => {
+ await updateConversionRate () {
+ try {
+ const currentCurrency = this.getCurrentCurrency()
+ const response = await fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`)
+ const parsedResponse = await response.json()
this.setConversionRate(Number(parsedResponse.bid))
this.setConversionDate(Number(parsedResponse.timestamp))
- }).catch((err) => {
- if (err) {
- console.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err)
- this.setConversionRate(0)
- this.setConversionDate('N/A')
- }
- })
+ } catch (err) {
+ console.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err)
+ this.setConversionRate(0)
+ this.setConversionDate('N/A')
+ }
}
scheduleConversionInterval () {