|
|
@@ -152,14 +152,19 @@ function DataTableContent() {
|
|
|
userAddress: string,
|
|
|
price: number
|
|
|
) => {
|
|
|
- const response = await fetch(
|
|
|
- `/api/my-lp/getBalanceByToken?tokenAddress=${tokenAddress}&accountAddress=${userAddress}`
|
|
|
- )
|
|
|
- const result = await response.json()
|
|
|
- setBalance(result.result.data.balance)
|
|
|
- setBalanceUsd(
|
|
|
- Number((Number(result.result.data.balance) * price).toFixed(2))
|
|
|
- )
|
|
|
+ try {
|
|
|
+ const response = await fetch(
|
|
|
+ `/api/my-lp/getBalanceByToken?tokenAddress=${tokenAddress}&accountAddress=${userAddress}`
|
|
|
+ )
|
|
|
+ const result = await response.json()
|
|
|
+ const bal = result?.result?.data?.balance
|
|
|
+ if (bal != null) {
|
|
|
+ setBalance(bal)
|
|
|
+ setBalanceUsd(Number((Number(bal) * price).toFixed(2)))
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.warn('fetchBalance failed:', e)
|
|
|
+ }
|
|
|
return true
|
|
|
}
|
|
|
|