GEOJSON!
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
|
||||
import type { Adventure } from '$lib/types';
|
||||
import type { Adventure, VisitedRegion } from '$lib/types';
|
||||
const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
|
||||
|
||||
export const load = (async (event) => {
|
||||
@@ -13,6 +13,20 @@ export const load = (async (event) => {
|
||||
Cookie: `${event.cookies.get('auth')}`
|
||||
}
|
||||
});
|
||||
|
||||
let visitedRegionsFetch = await fetch(`${endpoint}/api/visitedregion/`, {
|
||||
headers: {
|
||||
Cookie: `${event.cookies.get('auth')}`
|
||||
}
|
||||
});
|
||||
let visitedRegions = (await visitedRegionsFetch.json()) as VisitedRegion[];
|
||||
|
||||
let USfetch = await fetch(`${endpoint}/static/data/us.json`);
|
||||
let USjson = await USfetch.json();
|
||||
if (!USjson) {
|
||||
console.error('Failed to fetch US GeoJSON');
|
||||
}
|
||||
|
||||
if (!visitedFetch.ok) {
|
||||
console.error('Failed to fetch visited adventures');
|
||||
return redirect(302, '/login');
|
||||
@@ -29,9 +43,12 @@ export const load = (async (event) => {
|
||||
type: adventure.type
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
props: {
|
||||
markers
|
||||
markers,
|
||||
USjson,
|
||||
visitedRegions
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user