Skip to content

Commit

Permalink
Error handling in detail page fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
Ales Zima committed Jun 12, 2024
1 parent cd2699d commit 2dc1a63
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pages/country/[code].astro
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down

0 comments on commit 2dc1a63

Please sign in to comment.