From 7567a7cf38cc5ab005def8f8e40789a53d567643 Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 28 Jul 2023 19:52:31 +0700 Subject: [PATCH] rm .catch --- src/hooks/useBasicChartData.ts | 12 ++++-------- src/hooks/useTokenInfo.ts | 16 ++++++---------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/hooks/useBasicChartData.ts b/src/hooks/useBasicChartData.ts index fd7c961b70..b9f0b4e0aa 100644 --- a/src/hooks/useBasicChartData.ts +++ b/src/hooks/useBasicChartData.ts @@ -75,8 +75,6 @@ const fetchKyberDataSWRWithHeader = async (url: string) => { headers: { 'accept-version': 'Latest', }, - }).catch(error => { - throw error }) if (res.status === 204) { @@ -93,16 +91,14 @@ const fetchCoingeckoDataSWR = async ([tokenAddresses, chainIds, timeFrame, coing ]): Promise => { return await Promise.all( [tokenAddresses[0], tokenAddresses[1]].map((address, i) => - KyberOauth2Api.get(generateCoingeckoUrl(coingeckoAPI, chainIds[i], address, timeFrame), { timeout: 5000 }) - .then(res => { + KyberOauth2Api.get(generateCoingeckoUrl(coingeckoAPI, chainIds[i], address, timeFrame), { timeout: 5000 }).then( + res => { if (res.status === 204) { throw new Error('No content') } return res.data - }) - .catch(error => { - throw error - }), + }, + ), ), ) } diff --git a/src/hooks/useTokenInfo.ts b/src/hooks/useTokenInfo.ts index 289faa3b66..0c5cbce575 100644 --- a/src/hooks/useTokenInfo.ts +++ b/src/hooks/useTokenInfo.ts @@ -26,16 +26,12 @@ export default function useTokenInfo(token: Token | undefined): { data: TokenInf const coingeckoAPI = useCoingeckoAPI() const fetcher = (url: string) => url - ? KyberOauth2Api.get(url) - .then(res => { - if (res.status === 204) { - throw new Error('No content') - } - return res.data - }) - .catch(error => { - throw error - }) + ? KyberOauth2Api.get(url).then(res => { + if (res.status === 204) { + throw new Error('No content') + } + return res.data + }) : Promise.reject({ data: {}, error: '' }) const tokenAddress = isSolana ? token?.address || '' : (token?.address || '').toLowerCase()