Skip to content

Commit

Permalink
minor(frontend): log subgraph chain id on fetch error
Browse files Browse the repository at this point in the history
  • Loading branch information
xykota committed Oct 26, 2023
1 parent 7f5841a commit bdd60a4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/frontend/src/hooks/useAllTimeStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ const useAllTimeStats = () => {
return useQuery(
['allTimeStats'],
async () => {
const responses = (await Promise.all(
Object.values(GRAPH_URLS).map(url =>
request(url, ALL_TIME_STATS_QUERY).catch((error: any) => {
console.error(`Failed to fetch data from ${url}:`, error);
const responses = await Promise.all(
Object.entries(GRAPH_URLS).map(([chainId, url]) =>
request(url, ALL_TIME_STATS_QUERY)
.then<AllTimeStatsResponse>()
.catch((error: any) => {
console.error(`Failed to fetch data for ${chainId}:`, error);

return { allTimeStats: { volumeUsd: '0' } };
})
return { allTimeStats: { volumeUsd: '0' } };
})
)
)) as AllTimeStatsResponse[];
);

const totalVolumeUsd = responses.reduce(
(sum: number, response: AllTimeStatsResponse) =>
Expand Down

0 comments on commit bdd60a4

Please sign in to comment.