refactor price alert endpoint
This commit is contained in:
parent
0d5c900966
commit
175330e86e
@ -1,17 +1,18 @@
|
|||||||
export const load = async ({ locals }) => {
|
export const load = async ({ locals }) => {
|
||||||
const { apiKey, apiURL, fastifyURL, user } = locals;
|
const { apiKey, apiURL, user } = locals;
|
||||||
|
|
||||||
const getPriceAlert = async () => {
|
const getPriceAlert = async () => {
|
||||||
const postData = { userId: user?.id };
|
const postData = { userId: user?.id };
|
||||||
const response = await fetch(fastifyURL + "/get-price-alert", {
|
const response = await fetch(apiURL + "/get-price-alert", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData),
|
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));
|
output = output?.sort((a, b) => a?.symbol?.localeCompare(b?.symbol));
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user