2024-08-05 14:38:44 +02:00
|
|
|
import type { LayoutServerLoad } from "./$types";
|
|
|
|
|
|
|
|
|
|
export const load: LayoutServerLoad = async ({ params, fetch, cookies }) => {
|
2024-08-01 18:09:35 +02:00
|
|
|
const websiteData = await fetch(`http://localhost:3000/website?id=eq.${params.websiteId}`, {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: `Bearer ${cookies.get("session_token")}`,
|
|
|
|
|
Accept: "application/vnd.pgrst.object+json"
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const homeData = await fetch(`http://localhost:3000/home?website_id=eq.${params.websiteId}`, {
|
2024-07-31 07:23:32 +02:00
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: `Bearer ${cookies.get("session_token")}`,
|
|
|
|
|
Accept: "application/vnd.pgrst.object+json"
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const website = await websiteData.json();
|
2024-08-01 18:09:35 +02:00
|
|
|
const home = await homeData.json();
|
2024-07-31 07:23:32 +02:00
|
|
|
|
|
|
|
|
return {
|
2024-08-01 18:09:35 +02:00
|
|
|
website,
|
|
|
|
|
home
|
2024-07-31 07:23:32 +02:00
|
|
|
};
|
|
|
|
|
};
|