diff --git a/index.html b/index.html index 62a4890..6447f98 100644 --- a/index.html +++ b/index.html @@ -1515,7 +1515,7 @@ console.log("Starting the app! Please Wait!") floDapps.setCustomPrivKeyInput(getSignedIn) floDapps.setAppObjectStores({ savedIds: {}, savedUserData: {} }) - await floExchangeAPI.init("FMxYC7gYZhouzqtHZukGnPiQ8nvG4CMzXM", "exchange") + await floExchangeAPI.init("exchange") console.log('Exchange API initialized!') floDapps.launchStartUp().then(result => { console.log(`Welcome ${floDapps.user.id}`); diff --git a/scripts/floTokenAPI.js b/scripts/floTokenAPI.js index 2973ffe..5032f8b 100644 --- a/scripts/floTokenAPI.js +++ b/scripts/floTokenAPI.js @@ -1,4 +1,4 @@ -(function (EXPORTS) { //floTokenAPI v1.2.1 +(function (EXPORTS) { //floTokenAPI v1.2.1a /* Token Operator to send/receive tokens via blockchain using API calls*/ 'use strict'; const tokenAPI = EXPORTS; @@ -68,9 +68,13 @@ const getBalance = tokenAPI.getBalance = function (floID, token = DEFAULT.currency) { return new Promise((resolve, reject) => { - fetch_api(`api/v2/floAddressInfo/${floID}`) - .then(result => resolve(result.floAddressBalances[token]?.balance || 0)) - .catch(error => reject(error)) + fetch_api(`api/v2/floAddressInfo/${floID}`).then(result => { + let token_balance = 0 + if(result.floAddressBalances != null && typeof result.floAddressBalances == "object" && token in result.floAddressBalances){ + token_balance = result.floAddressBalances[token]["balance"] || 0 + } + resolve(token_balance) + }).catch(error => reject(error)) }) }