Skip to content

Commit

Permalink
fix: guardrail to requests
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizAsFight committed Nov 22, 2024
1 parent 7c74b1c commit 5de214e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
24 changes: 13 additions & 11 deletions packages/app/src/systems/Asset/services/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AssetData>;
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<AssetData>;
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']) {
Expand Down
14 changes: 10 additions & 4 deletions packages/app/src/systems/Core/utils/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ export const graphqlRequest = async <R, T = Record<string, unknown>>(
});

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(_);
}
};

0 comments on commit 5de214e

Please sign in to comment.