frontend/src/routes/index/[tickerID]/history/+page.server.ts
MuslemRahimi 5b500ae3f9 add index
2025-02-09 22:17:13 +01:00

26 lines
563 B
TypeScript

export const load = async ({ locals, params }) => {
const { apiKey, apiURL } = locals;
const getData = async () => {
const postData = { ticker: params.tickerID, timePeriod: 'max' };
const response = await fetch(apiURL + "/historical-price", {
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 {
getData: await getData(),
};
};