We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 89e299c commit e9d554bCopy full SHA for e9d554b
src/pages/index.tsx
@@ -29,12 +29,20 @@ export const HomePage = (props: InferGetStaticPropsType<typeof getStaticProps>)
29
export default HomePage;
30
31
export const getStaticProps = (async () => {
32
- const res = await fetch("https://api.github.com/repos/AykutSarac/jsoncrack.com");
33
- const data = await res.json();
+ try {
+ const res = await fetch("https://api.github.com/repos/AykutSarac/jsoncrack.com");
34
+ const data = await res.json();
35
- return {
36
- props: {
37
- stars: data.stargazers_count,
38
- },
39
- };
+ return {
+ props: {
+ stars: data?.stargazers_count || 0,
+ },
40
+ };
41
+ } catch (error) {
42
43
44
+ stars: 0,
45
46
47
+ }
48
}) satisfies GetStaticProps<{ stars: number }>;
0 commit comments