frontend/src/routes/stocks/+page.server.ts
2024-11-16 23:43:04 +01:00

25 lines
613 B
TypeScript

export const load = async ({ locals }) => {
const getStockList = async () => {
const { apiKey, apiURL } = locals;
const postData = {'filterList': 'all-stock-tickers'}
// make the POST request to the endpoint
const response = await fetch(apiURL + "/list-category", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": apiKey,
},
body: JSON.stringify(postData)
});
const output = await response.json();
return output;
};
// Make sure to return a promise
return {
getStockList: await getStockList(),
};
};