Skip to content

Commit

Permalink
rm .catch
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh committed Jul 28, 2023
1 parent 1489e06 commit 7567a7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
12 changes: 4 additions & 8 deletions src/hooks/useBasicChartData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ const fetchKyberDataSWRWithHeader = async (url: string) => {
headers: {
'accept-version': 'Latest',
},
}).catch(error => {
throw error
})

if (res.status === 204) {
Expand All @@ -93,16 +91,14 @@ const fetchCoingeckoDataSWR = async ([tokenAddresses, chainIds, timeFrame, coing
]): Promise<any> => {
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
}),
},
),
),
)
}
Expand Down
16 changes: 6 additions & 10 deletions src/hooks/useTokenInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 7567a7c

Please sign in to comment.