Skip to content

Commit 0dfb256

Browse files
committed
Fix block fetching
1 parent 893c08c commit 0dfb256

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

components/widgets/TransactionsWidget.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const getPercentageRatio = (v) => {
8686
}
8787
8888
const getSectorName = (item) => {
89-
return item.time ? DateTime.fromISO(item.time).hour : DateTime.now().hour
89+
return item?.time ? DateTime.fromISO(item?.time).hour : DateTime.now().hour
9090
}
9191
</script>
9292

services/api/block.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,47 @@ export const fetchLatestBlocks = async ({ limit }) => {
7474
}
7575
}
7676

77+
// export const fetchAvgBlockTime = async ({ from }) => {
78+
// try {
79+
// const url = new URL(`${useServerURL()}/stats/summary/block_stats/avg?column=block_time`)
80+
81+
// url.searchParams.append("from", from)
82+
83+
// const data = await useFetch(url.href)
84+
// return data
85+
// } catch (error) {
86+
// console.error(error)
87+
// }
88+
// }
89+
90+
// export const fetchBlockByHeight = async (height) => {
91+
// try {
92+
// const data = await useFetch(`${useServerURL()}/block/${height}?stats=true`)
93+
// return data
94+
// } catch (error) {
95+
// console.error(error)
96+
// }
97+
// }
98+
7799
export const fetchAvgBlockTime = async ({ from }) => {
78100
try {
79101
const url = new URL(`${useServerURL()}/stats/summary/block_stats/avg?column=block_time`)
80102

81103
url.searchParams.append("from", from)
82104

83-
const data = await useFetch(url.href)
84-
return data
105+
return useFetch(url.href, {
106+
key: "avg_block_time",
107+
})
85108
} catch (error) {
86109
console.error(error)
87110
}
88111
}
89112

90113
export const fetchBlockByHeight = async (height) => {
91114
try {
92-
const data = await useFetch(`${useServerURL()}/block/${height}?stats=true`)
93-
return data
115+
return useFetch(`${useServerURL()}/block/${height}?stats=true`, {
116+
key: "block",
117+
})
94118
} catch (error) {
95119
console.error(error)
96120
}

0 commit comments

Comments
 (0)