From c7058b83c8c0fe79e6712c96d0800c083d737e16 Mon Sep 17 00:00:00 2001 From: xHyroM Date: Sat, 8 Apr 2023 13:30:01 +0200 Subject: [PATCH] build: investigate why fetching doesnt work fixed probably --- src/pages/projects.astro | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/pages/projects.astro b/src/pages/projects.astro index 0bb5ec9..03d148b 100644 --- a/src/pages/projects.astro +++ b/src/pages/projects.astro @@ -41,7 +41,7 @@ const projects: Project[] = [ }, { name: "setup-bun", - link: "https://github.com/xHyroM/setup-bun", + link: "https://github.com/oven-sh/setup-bun", desc: "Set up your GitHub Actions workflow with a specific version of Bun.", }, { @@ -93,15 +93,24 @@ const projects: Project[] = [ for (const project of projects) { try { - const repository = await ( - await fetch(`https://api.github.com/repos/${project.link.slice(19)}`, { + const rawRepository = await fetch( + `https://api.github.com/repos/${project.link.slice(19)}`, + { headers: { Authorization: `Bearer ${import.meta.env.GITHUB_ACCESS_TOKEN}`, }, - }) - ).json(); + } + ).catch(console.log); + if (!rawRepository) { + project.stats = { + forks: 0, + stars: 0, + }; - console.log(repository); //debug + continue; + } + + const repository = await rawRepository.json(); project.stats = { forks: repository.forks,