diff --git a/dist/esm/index.js b/dist/esm/index.js index 020b83a..8b7e982 100644 --- a/dist/esm/index.js +++ b/dist/esm/index.js @@ -56,19 +56,21 @@ var getAssets = async (options) => { fetch(`https://public.depay.fi/accounts/${blockchain}/${address}/assets`, { signal: controller.signal }) .catch((error) => { console.log(error); resolve([]); }) .then((response) => { - if(response.success) { + if(response && response.success) { return response.json() } else { resolve([]); } }) .then(async (assets) => { - return await ensureNativeTokenAsset({ - address, - options, - assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })), - blockchain - }) + if(assets && assets.length) { + return await ensureNativeTokenAsset({ + address, + options, + assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })), + blockchain + }) + } }) .then(resolve) .catch((error) => { console.log(error); resolve([]); }); diff --git a/dist/umd/index.js b/dist/umd/index.js index f39769b..005ffaf 100644 --- a/dist/umd/index.js +++ b/dist/umd/index.js @@ -57,19 +57,21 @@ fetch(`https://public.depay.fi/accounts/${blockchain}/${address}/assets`, { signal: controller.signal }) .catch((error) => { console.log(error); resolve([]); }) .then((response) => { - if(response.success) { + if(response && response.success) { return response.json() } else { resolve([]); } }) .then(async (assets) => { - return await ensureNativeTokenAsset({ - address, - options, - assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })), - blockchain - }) + if(assets && assets.length) { + return await ensureNativeTokenAsset({ + address, + options, + assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })), + blockchain + }) + } }) .then(resolve) .catch((error) => { console.log(error); resolve([]); });