From 2dc1a63275aefd72741bd7ff78a21df7197aee98 Mon Sep 17 00:00:00 2001 From: Ales Zima Date: Wed, 12 Jun 2024 14:37:37 +0200 Subject: [PATCH] Error handling in detail page fetching --- src/pages/country/[code].astro | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/country/[code].astro b/src/pages/country/[code].astro index c2cbeb6..aa0f5a5 100644 --- a/src/pages/country/[code].astro +++ b/src/pages/country/[code].astro @@ -6,7 +6,12 @@ import type { Country } from '../../types/country'; const country: Country = Astro.props; export const getStaticPaths = async () => { - const countryData = await fetchCountryData(); + let countryData: Country[] = []; + try { + countryData = await fetchCountryData(); + } catch (error) { + console.log(error); + } async function fetchCountryData() { const url = new URL(`${import.meta.env.API_BASE_URL}/country.json`);