From 5de214e2888799ad53864145b4044f960932d6f6 Mon Sep 17 00:00:00 2001 From: LuizAsFight Date: Fri, 22 Nov 2024 13:40:10 -0300 Subject: [PATCH] fix: guardrail to requests --- .../app/src/systems/Asset/services/assets.ts | 24 ++++++++++--------- .../app/src/systems/Core/utils/graphql.ts | 14 +++++++---- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/packages/app/src/systems/Asset/services/assets.ts b/packages/app/src/systems/Asset/services/assets.ts index 016edfd73..6bd509a8c 100644 --- a/packages/app/src/systems/Asset/services/assets.ts +++ b/packages/app/src/systems/Asset/services/assets.ts @@ -47,19 +47,21 @@ export class AssetService { } static async setListedAssets() { - const verifiedAssets = (await ( - await fetch('https://verified-assets.fuel.network/assets.json') - ).json()) as Array; - const assetsPromises = verifiedAssets.map((asset) => { - return AssetService.upsertAsset({ - data: { - ...asset, - isCustom: false, - }, + try { + const verifiedAssets = (await ( + await fetch('https://verified-assets.fuel.network/assets.json') + ).json()) as Array; + const assetsPromises = verifiedAssets.map((asset) => { + return AssetService.upsertAsset({ + data: { + ...asset, + isCustom: false, + }, + }); }); - }); - await Promise.all(assetsPromises); + await Promise.all(assetsPromises); + } catch (_) {} } static async updateAsset(input: AssetInputs['updateAsset']) { diff --git a/packages/app/src/systems/Core/utils/graphql.ts b/packages/app/src/systems/Core/utils/graphql.ts index 55a98bd11..cf62a7fb4 100644 --- a/packages/app/src/systems/Core/utils/graphql.ts +++ b/packages/app/src/systems/Core/utils/graphql.ts @@ -28,10 +28,16 @@ export const graphqlRequest = async >( }); if (res.ok) { - const response = await res.json(); - return response.data as R; + try { + const response = await res.json(); + return response.data as R; + } catch (_) {} } - const error = await res.json(); - return Promise.reject(error); + try { + const error = await res.json(); + return Promise.reject(error); + } catch (_) { + return Promise.reject(_); + } };