frontend/src/routes/api/historical-price/+server.ts
MuslemRahimi 692e6fe237 ui fix
2024-10-23 14:26:46 +02:00

21 lines
596 B
TypeScript

import type { RequestHandler } from "./$types";
export const POST: RequestHandler = async ({ request, locals }) => {
const data = await request.json();
const { apiURL, apiKey } = locals;
const postData = { ticker: data?.ticker, timePeriod: data?.timePeriod };
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 new Response(JSON.stringify(output));
};