frontend/src/routes/stocks/[tickerID]/stats/cash-flow/+page.server.ts
2024-09-20 01:14:48 +02:00

29 lines
654 B
TypeScript

export const load = async ({ locals, params }) => {
const getCashFlowStatement = async () => {
const { apiKey, apiURL } = locals;
const postData = {
ticker: params.tickerID,
};
// make the POST request to the endpoint
const response = await fetch(apiURL + "/stock-cash-flow", {
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 {
getCashFlowStatement: await getCashFlowStatement(),
};
};