Skip to content

Commit

Permalink
Merge pull request #7 from kaiachain/feat/remove-cors
Browse files Browse the repository at this point in the history
Added error handling
  • Loading branch information
praveen-kaia authored Oct 14, 2024
2 parents c6ca252 + a5d341e commit 3830800
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,27 @@ const UNIQUE_ACTIVE_CONTRACTS_SQL = `WITH from_addresses AS (
FROM active_contracts`;

const loadData = async (_query, _dataElement) => {
const queryResultSetTxnCount = await flipside.query.run({ sql: _query });

let results = await flipside.query.getQueryResults({
queryRunId: queryResultSetTxnCount.queryId,
pageNumber: 1,
pageSize: 1,
});

if (results.error) {
throw results.error;
}
if (results.records && results.records.length > 0) {
StatsData[_dataElement] = results.records[0][_dataElement];
console.log(`Updated ${_dataElement}: ` + results.records[0][_dataElement]);
try {
const queryResultSetTxnCount = await flipside.query.run({ sql: _query });

let results = await flipside.query.getQueryResults({
queryRunId: queryResultSetTxnCount.queryId,
pageNumber: 1,
pageSize: 1,
});

if (results.error) {
throw results.error;
}
if (results.records && results.records.length > 0) {
StatsData[_dataElement] = results.records[0][_dataElement];
console.log(`Updated ${_dataElement}: ` + results.records[0][_dataElement]);
}
} catch(err) {
console.log("Error while fetching "+_dataElement)
console.log(err);
}

};

const loadCoingeckoData = (_dataElement) => {
Expand Down

0 comments on commit 3830800

Please sign in to comment.