Skip to content

Commit 8babad2

Browse files
refactor: simplify API fetch error handling in aa-chains route
1 parent 0e26a88 commit 8babad2

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

apps/portal/src/app/api/aa-chains/route.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,12 @@ export async function GET() {
1414
headers: {
1515
"Content-Type": "application/json",
1616
},
17-
})
18-
.then((res) => res.json() as Promise<ApiResponseType>)
19-
.catch((error) => {
20-
console.error(error);
21-
return { data: {} as ApiResponseType["data"] };
22-
}),
17+
}).then((res) => res.json() as Promise<ApiResponseType>),
2318
fetch("https://api.thirdweb.com/v1/chains", {
2419
headers: {
2520
"Content-Type": "application/json",
2621
},
27-
})
28-
.then((res) => res.json() as Promise<{ data: ChainMetadata[] }>)
29-
.catch((error) => {
30-
console.error(error);
31-
return { data: [] as ChainMetadata[] };
32-
}),
22+
}).then((res) => res.json() as Promise<{ data: ChainMetadata[] }>),
3323
]);
3424

3525
const aaChains = Object.entries(chainsWithServices.data)

apps/portal/src/components/Document/AAChainList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ async function getChains(): Promise<ChainMetadata[]> {
77
try {
88
const chains = await fetch(`${getBaseUrl()}/api/aa-chains`);
99
if (!chains.ok) {
10+
console.error("Failed to fetch chains", chains.statusText);
1011
return [];
1112
}
1213
const result = (await chains.json()) as { data: ChainMetadata[] };
1314
return result.data;
1415
} catch (error) {
15-
console.error(error);
16+
console.error("Failed to fetch chains", error);
1617
return [];
1718
}
1819
}

0 commit comments

Comments
 (0)