frontend/src/routes/ipos/[slug]/+page.server.ts
MuslemRahimi 191d3f1d0c ui fixes
2024-09-21 16:56:59 +02:00

31 lines
707 B
TypeScript

export const load = async ({ locals, params }) => {
const getIPOCalendar = async () => {
const { apiURL, apiKey } = locals;
// make the POST request to the endpoint
const postData = { year: params.slug };
const response = await fetch(apiURL + "/ipo-calendar", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": apiKey,
},
body: JSON.stringify(postData),
});
const output = await response.json();
return output;
};
const getYear = async () => {
return params.slug;
};
// Make sure to return a promise
return {
getIPOCalendar: await getIPOCalendar(),
getYear: await getYear(),
};
};