Skip to content

Commit 87f043e

Browse files
committed
feat: add lib/api/stablecoinsData.ts
1 parent 68aa277 commit 87f043e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/lib/api/stablecoinsData.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { COINGECKO_API_BASE_URL, COINGECKO_API_URL_PARAMS } from "../constants"
2+
3+
export async function fetchEthereumEcosystemData() {
4+
const url = `${COINGECKO_API_BASE_URL}ethereum-ecosystem${COINGECKO_API_URL_PARAMS}`
5+
6+
try {
7+
const ethereumEcosystemData = await fetch(url).then((res) => res.json())
8+
9+
return ethereumEcosystemData
10+
} catch (error) {
11+
// In production mode, throw an error to stop the build in case this fetch fails
12+
console.error(error)
13+
throw new Error(
14+
"Something went wrong with requesting the Ethereum ecosystem data."
15+
)
16+
}
17+
}
18+
19+
export async function fetchEthereumStablecoinsData() {
20+
const url = `${COINGECKO_API_BASE_URL}stablecoins${COINGECKO_API_URL_PARAMS}`
21+
22+
try {
23+
const ethereumStablecoinsData = await fetch(url).then((res) => res.json())
24+
25+
return ethereumStablecoinsData
26+
} catch (error) {
27+
// In production mode, throw an error to stop the build in case this fetch fails
28+
console.error(error)
29+
throw new Error(
30+
"Something went wrong with requesting the Ethereum ecosystem data."
31+
)
32+
}
33+
}

0 commit comments

Comments
 (0)