Skip to content

Commit

Permalink
Show error message if config.json can't be found
Browse files Browse the repository at this point in the history
  • Loading branch information
MyIgel authored and skorpy2009 committed Oct 17, 2023
1 parent 31386a7 commit b71c734
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Thumbs.db
# Project files
/node_modules
/build
/config.js
/config.json
*.zip
/dev-dist
/public/config.json
12 changes: 12 additions & 0 deletions lib/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ import { main } from "./main";

export const load = async () => {
const configResponse = await fetch("config.json");
if (!configResponse.ok) {
document.querySelector(".loader").innerHTML =
"config.json can not be loaded:" +
"<br>" +
configResponse.statusText +
"<br><br>" +
'<button onclick="location.reload(true)" class="btn text" aria-label="Try to reload">' +
"Try to reload" +
"</button><br>" +
"or report to your community";
return;
}
const config = await configResponse.json();
globalThis.config = Object.assign(defaultConfig, config);
main();
Expand Down

0 comments on commit b71c734

Please sign in to comment.