Commit ceed5e0b authored by cartcrom's avatar cartcrom Committed by GitHub

fix: always return arrays from typed queries (#5382)

added empty array fallbacks
parent a4493382
...@@ -15,8 +15,7 @@ export const fetchSearchTokens = async (tokenQuery: string): Promise<FungibleTok ...@@ -15,8 +15,7 @@ export const fetchSearchTokens = async (tokenQuery: string): Promise<FungibleTok
const data = await r.json() const data = await r.json()
// TODO Undo favoritism // TODO Undo favoritism
return ( return data.data
data.data && ? data.data.sort((a: FungibleToken, b: FungibleToken) => (b.name === 'Uniswap' ? 1 : b.volume24h - a.volume24h))
data.data.sort((a: FungibleToken, b: FungibleToken) => (b.name === 'Uniswap' ? 1 : b.volume24h - a.volume24h)) : []
)
} }
...@@ -18,5 +18,5 @@ export const fetchTrendingCollections = async (payload: { ...@@ -18,5 +18,5 @@ export const fetchTrendingCollections = async (payload: {
const data = await r.json() const data = await r.json()
return data return data ?? []
} }
...@@ -15,5 +15,5 @@ export const fetchTrendingTokens = async (numTokens?: number): Promise<FungibleT ...@@ -15,5 +15,5 @@ export const fetchTrendingTokens = async (numTokens?: number): Promise<FungibleT
}) })
const { data } = (await r.json()) as { data: FungibleToken[] } const { data } = (await r.json()) as { data: FungibleToken[] }
return data.map((token) => unwrapToken(token.chainId, token)) return data ? data.map((token) => unwrapToken(token.chainId, token)) : []
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment