From 175330e86e2359cecaa038782fe4528321db96ad Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 25 Nov 2024 19:35:55 +0100 Subject: [PATCH] refactor price alert endpoint --- src/routes/price-alert/+page.server.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/routes/price-alert/+page.server.ts b/src/routes/price-alert/+page.server.ts index 967a6e74..c0021e1a 100644 --- a/src/routes/price-alert/+page.server.ts +++ b/src/routes/price-alert/+page.server.ts @@ -1,17 +1,18 @@ export const load = async ({ locals }) => { - const { apiKey, apiURL, fastifyURL, user } = locals; + const { apiKey, apiURL, user } = locals; const getPriceAlert = async () => { const postData = { userId: user?.id }; - const response = await fetch(fastifyURL + "/get-price-alert", { + const response = await fetch(apiURL + "/get-price-alert", { method: "POST", headers: { "Content-Type": "application/json", + "X-API-KEY": apiKey, }, body: JSON.stringify(postData), }); - let output = (await response.json())?.items; + let output = await response.json(); output = output?.sort((a, b) => a?.symbol?.localeCompare(b?.symbol)); return output;