mirror of
https://github.com/KevinMidboe/planetposen-frontend.git
synced 2026-02-15 03:39:06 +00:00
All planetposen routes at version 0.1
This commit is contained in:
16
src/routes/shop/[id]/+page.server.ts
Normal file
16
src/routes/shop/[id]/+page.server.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { dev } from '$app/environment';
|
||||
import { env } from '$env/dynamic/private';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, params }) => {
|
||||
const { id } = params;
|
||||
|
||||
let url = `/api/product/${id}`;
|
||||
if (dev || env.API_HOST) {
|
||||
url = (env.API_HOST || 'http://localhost:30010').concat(url);
|
||||
}
|
||||
|
||||
const res = await fetch(url);
|
||||
const product = await res.json();
|
||||
return product;
|
||||
};
|
||||
Reference in New Issue
Block a user