fix: Added error handling for data calls
Some checks failed
Build Gameflow Site / build (push) Failing after 1m1s

This commit is contained in:
Simeon Radivoev 2026-05-07 00:26:35 +03:00
parent cb0ef9207d
commit ea97172142
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A

View file

@ -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[];
});