diff --git a/src/scripts/getters.ts b/src/scripts/getters.ts index 62e8f9f..31a490f 100644 --- a/src/scripts/getters.ts +++ b/src/scripts/getters.ts @@ -9,25 +9,61 @@ const githubHeaders = import.meta.env.GITHUB_TOKEN export const repoData = await fetch( "https://api.github.com/repos/simeonradivoev/gameflow-deck", githubHeaders, -).then((res) => res.json()); +) + .then((res) => { + if (!res.ok) throw new Error(res.statusText); + return res.json(); + }) + .catch((e) => { + console.error(e); + return { stargazers_count: 0 }; + }); export const releaseData = await fetch( "https://api.github.com/repos/simeonradivoev/gameflow-deck/releases/latest", githubHeaders, -).then((res) => res.json()); +) + .then((res) => { + if (!res.ok) throw new Error(res.statusText); + return res.json(); + }) + .catch((e) => { + console.error(e); + return { tag_name: "unknown" }; + }); export const appContributorsData = await fetch( "https://api.github.com/repos/simeonradivoev/gameflow-deck/contributors", githubHeaders, -).then((res) => res.json()); +) + .then((res) => { + if (!res.ok) throw new Error(res.statusText); + return res.json(); + }) + .catch((e) => { + console.error(e); + return []; + }); export const storeContributorsData = await fetch( "https://api.github.com/repos/simeonradivoev/gameflow-store/contributors", githubHeaders, -).then((res) => res.json()); +) + .then((res) => { + if (!res.ok) throw new Error(res.statusText); + return res.json(); + }) + .catch((e) => { + console.error(e); + return []; + }); export const emulators = await fetch( "https://cdn.jsdelivr.net/npm/@simeonradivoev/gameflow-store@latest/manifests/emulators.json", ) .then((res) => res.json()) - .then((d) => d.emulators as any[]); + .then((d) => d.emulators as any[]) + .catch((e) => { + console.error(e); + return [] as any[]; + });