Skip to content

Commit

Permalink
Fix startup with no data (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachk authored Feb 5, 2024
1 parent 82d7497 commit 08ea66f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions api/src/load-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ let data: Data = {
let timer: ReturnType<typeof setTimeout> | null = null;

const loadData = (eventType?: string) => {
const f = () => {
data = JSON.parse(fs.readFileSync(dataLocation, "utf8"));
console.log(`Loaded data (written at ${data.lastUpdated}).`);
};

try {
const f = () => {
data = JSON.parse(fs.readFileSync(dataLocation, "utf8"));
console.log(`Loaded data (written at ${data.lastUpdated}).`);
};
} catch (err) {
console.log(`Failed loading data error ${err}.`);
}

if (eventType) {
if (timer != null) {
clearTimeout(timer);
Expand Down

0 comments on commit 08ea66f

Please sign in to comment.