fix: Added error handling for data calls
Some checks failed
Build Gameflow Site / build (push) Failing after 1m1s
Some checks failed
Build Gameflow Site / build (push) Failing after 1m1s
This commit is contained in:
parent
cb0ef9207d
commit
ea97172142
1 changed files with 41 additions and 5 deletions
|
|
@ -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[];
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue