Skip to content

Commit

Permalink
feat: handle 422 error from block transactions api
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Aug 17, 2023
1 parent e1987ad commit e56a348
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/pages/BlockDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,23 @@ export default () => {
['block-transactions', blockHash, currentPage, pageSizeParam, filter],
async () => {
assert(blockHash != null)
const { data, meta } = await fetchTransactionsByBlockHash(blockHash, {
page: currentPage,
size: pageSizeParam,
filter,
})
return {
transactions: data.map(wrapper => wrapper.attributes),
total: meta?.total ?? 0,
pageSize: meta?.pageSize,
try {
const { data, meta } = await fetchTransactionsByBlockHash(blockHash, {
page: currentPage,
size: pageSizeParam,
filter,
})
return {
transactions: data.map(wrapper => wrapper.attributes),
total: meta?.total ?? 0,
pageSize: meta?.pageSize,
}
} catch (e) {
console.error(e)
return {
transactions: [],
total: 0,
}
}
},
{
Expand Down

0 comments on commit e56a348

Please sign in to comment.