bugfixing

This commit is contained in:
MuslemRahimi 2024-08-01 22:25:00 +02:00
parent 014194d61d
commit 72a8a40b33
2 changed files with 5 additions and 31 deletions

View File

@ -3,31 +3,6 @@ import { validateData } from "$lib/utils";
import { loginUserSchema, registerUserSchema } from "$lib/schemas";
export const load = async () => {
const apiKey = import.meta.env.VITE_LEMON_SQUEEZY_API_KEY;
const getLTDCount = async () => {
// make the POST request to the endpoint
const response = await fetch('https://api.lemonsqueezy.com/v1/order-items?page[size]=100', {
headers: {
'Accept': 'application/vnd.api+json',
'Content-Type': 'application/vnd.api+json',
'Authorization': `Bearer ${apiKey}`
}
});
const output = await response.json();
const filteredData = output?.data?.filter(item => item?.attributes?.product_name === 'Pro Subscription (Life Time Access)');
const count = filteredData?.length || 0;
return count;
};
return {
getLTDCount: await getLTDCount(),
};
};
async function checkDisposableEmail(email) {
const url = `https://disposable.debounce.io/?email=${encodeURIComponent(email)}`;

View File

@ -2,22 +2,21 @@ import { getCache, setCache } from '$lib/store';
import { redirect } from '@sveltejs/kit';
export const load = async ({ parent}) => {
export const load = async ({parent}) => {
const { user, apiKey, apiURL } = await parent();
if (!user) {
redirect(303, '/');
}
const getDashboard = async () => {
let output;
// Get cached data for the specific tickerID
const cachedData = getCache('', 'getDashboard');
if (cachedData) {
output = cachedData;
return cachedData;
} else {
const response = await fetch(apiURL + '/dashboard-info', {
@ -27,10 +26,10 @@ export const load = async ({ parent}) => {
},
});
output = await response.json();
const output = await response?.json();
setCache('', output, 'getDashboard');
return output;
}
return output;
};
// Make sure to return a promise