errors and not found screens
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user