From 5adef49cecfa5cecc4d6393a1a1a4e56bfd5d91a Mon Sep 17 00:00:00 2001 From: xHyroM Date: Sat, 8 Apr 2023 13:20:27 +0200 Subject: [PATCH] build: investigate why fetching doesnt work --- src/pages/projects.astro | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/pages/projects.astro b/src/pages/projects.astro index b0560db..0bb5ec9 100644 --- a/src/pages/projects.astro +++ b/src/pages/projects.astro @@ -92,21 +92,24 @@ const projects: Project[] = [ ]; for (const project of projects) { - const repository = await ( - await fetch(`https://api.github.com/repos/${project.link.slice(19)}`, { - headers: { - Authorization: `Bearer ${import.meta.env.GITHUB_ACCESS_TOKEN}`, - }, - }) - ).json(); + try { + const repository = await ( + await fetch(`https://api.github.com/repos/${project.link.slice(19)}`, { + headers: { + Authorization: `Bearer ${import.meta.env.GITHUB_ACCESS_TOKEN}`, + }, + }) + ).json(); - console.log(import.meta.env); - console.log(repository); //debug + console.log(repository); //debug - project.stats = { - forks: repository.forks, - stars: repository.stargazers_count, - }; + project.stats = { + forks: repository.forks, + stars: repository.stargazers_count, + }; + } catch (e) { + console.log(e); + } } projects.sort((a, b) => a.name.localeCompare(b.name));