Skip to content

Commit 1064698

Browse files
committed
Fix error handling in index.html
1 parent 67bc9fc commit 1064698

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

demo/index.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77

88
<script>
99
(async function () {
10-
const stage = (await fetch('http://localhost:3000/stage?number=1').then(res => res.json()))[0];
11-
const data = await fetch('http://localhost:3000/db').then(res => res.json());
10+
const data = await fetch('http://localhost:3000/db')
11+
.catch(() => alert('Failed to fetch localhost. Please do `npm run db` or use json-server your own way.'))
12+
.then(res => res.json());
1213

1314
bracketsViewer.render('#root', {
14-
stage,
15+
stage: data.stage[0],
1516
groups: data.group,
1617
rounds: data.round,
1718
matches: data.match,
@@ -23,7 +24,5 @@
2324
showLowerBracketSlotsOrigin: true,
2425
highlightParticipantOnHover: true,
2526
});
26-
})().catch(() => {
27-
alert('Failed to fetch localhost. Please do `npm run db` or use json-server your own way.');
28-
});
27+
})()
2928
</script>

0 commit comments

Comments
 (0)