errors and not found screens

This commit is contained in:
Sean Morley
2024-07-10 18:21:52 -04:00
parent b3878bff72
commit a6b1d421cc
3 changed files with 42 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
import type { Country, Region, VisitedRegion } from '$lib/types';
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
@@ -19,16 +20,11 @@ export const load = (async (event) => {
});
if (!res.ok) {
console.error('Failed to fetch regions');
return { status: 500 };
return redirect(302, '/404');
} else {
regions = (await res.json()) as Region[];
}
if (regions.length === 0) {
console.error('No regions found');
return { status: 404 };
}
res = await fetch(`${endpoint}/api/${id}/visits/`, {
method: 'GET',
headers: {