frontend/src/routes/market-mover/+page.server.ts
2024-09-20 01:14:48 +02:00

39 lines
936 B
TypeScript

export const load = async ({ locals, setHeaders }) => {
const { apiURL, apiKey } = locals;
const getDailyGainerLoserActive = async () => {
const response = await fetch(apiURL + "/market-movers", {
method: "GET",
headers: {
"Content-Type": "application/json",
"X-API-KEY": apiKey,
},
});
const output = await response.json();
return output;
};
const getMiniPlotsIndex = async () => {
const response = await fetch(apiURL + "/mini-plots-index", {
method: "GET",
headers: {
"Content-Type": "application/json",
"X-API-KEY": apiKey,
},
});
const output = await response.json();
return output;
};
setHeaders({ "cache-control": "public, max-age=3000" });
// Make sure to return a promise
return {
getDailyGainerLoserActive: await getDailyGainerLoserActive(),
getMiniPlotsIndex: await getMiniPlotsIndex(),
};
};