From 04e662526827e581528b6ebd120b0d70920815d1 Mon Sep 17 00:00:00 2001 From: mrkeays <160034476+Mkeays501@users.noreply.github.com> Date: Sat, 31 Aug 2024 09:30:34 -0300 Subject: [PATCH] Update trending.js robustness added --- trending.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/trending.js b/trending.js index 14e53bb..23f20a0 100644 --- a/trending.js +++ b/trending.js @@ -1,7 +1,10 @@ -export async function fetchTrendingRepos() { +export async function fetchTrendingRepos(): Promise { try { const response = await fetch('/backend/api/trending'); - const repos = await response.json(); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const repos: RepoType[] = await response.json(); return repos; } catch (error) { console.error('Error fetching trending repositories:', error);