frontend/src/routes/etf/[tickerID]/insider/+page.server.ts
2024-11-17 16:51:49 +01:00

27 lines
614 B
TypeScript

export const load = async ({ locals, params }) => {
const getSenateTrading = async () => {
const { apiKey, apiURL } = locals;
const postData = {
ticker: params.tickerID,
};
// make the POST request to the endpoint
const response = await fetch(apiURL + "/congress-trading-ticker", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": apiKey,
},
body: JSON.stringify(postData),
});
const output = await response.json();
return output;
};
return {
getSenateTrading: await getSenateTrading(),
};
};