Skip to content

Commit 42a7b20

Browse files
committed
Set coin prices to zero if CoinGecko fails
1 parent 9231a41 commit 42a7b20

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/api/utils/coingecko.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,17 @@ export class CoinGeckoDataService {
7171
const vsCurrenciesParams = `vs_currencies=${params.vsCurrencies.join(',')}`;
7272
const url = `${endpoint}${contractAddressParams}&${vsCurrenciesParams}`;
7373

74-
const response = await axios.get(url);
74+
let response;
75+
try {
76+
response = await axios.get(url);
77+
} catch (e) {
78+
// If coingecko fails, set prices to zero
79+
response = { data: {} };
80+
for (const address of params.contractAddresses) {
81+
response.data[address] = {};
82+
response.data[address][params.vsCurrencies[0]] = 0.00;
83+
}
84+
}
7585
return response.data;
7686
}
7787

0 commit comments

Comments
 (0)