add try catch for recent trades
This commit is contained in:
parent
a14431ac2e
commit
f68cbbc4d2
|
@ -30,17 +30,21 @@ const RecentTrades = () => {
|
|||
const fetchTradesForChart = useCallback(async () => {
|
||||
if (!selectedMarketPk) return
|
||||
|
||||
const response = await fetch(
|
||||
`https://event-history-api-candles.herokuapp.com/trades/address/${selectedMarketPk}`
|
||||
)
|
||||
const parsedResp = await response.json()
|
||||
const newTrades = parsedResp.data
|
||||
if (!newTrades) return null
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://event-history-api-candles.herokuapp.com/trades/address/${selectedMarketPk}`
|
||||
)
|
||||
const parsedResp = await response.json()
|
||||
const newTrades = parsedResp.data
|
||||
if (!newTrades) return null
|
||||
|
||||
if (newTrades.length && trades.length === 0) {
|
||||
setTrades(newTrades)
|
||||
} else if (newTrades?.length && !isEqual(newTrades[0], trades[0])) {
|
||||
setTrades(newTrades)
|
||||
if (newTrades.length && trades.length === 0) {
|
||||
setTrades(newTrades)
|
||||
} else if (newTrades?.length && !isEqual(newTrades[0], trades[0])) {
|
||||
setTrades(newTrades)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Unable to fetch recent trades', e)
|
||||
}
|
||||
}, [selectedMarketPk, trades])
|
||||
|
||||
|
|
Loading…
Reference in New Issue