bugfixing
This commit is contained in:
parent
014194d61d
commit
72a8a40b33
@ -3,31 +3,6 @@ import { validateData } from "$lib/utils";
|
|||||||
import { loginUserSchema, registerUserSchema } from "$lib/schemas";
|
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) {
|
async function checkDisposableEmail(email) {
|
||||||
const url = `https://disposable.debounce.io/?email=${encodeURIComponent(email)}`;
|
const url = `https://disposable.debounce.io/?email=${encodeURIComponent(email)}`;
|
||||||
|
|||||||
@ -2,22 +2,21 @@ import { getCache, setCache } from '$lib/store';
|
|||||||
import { redirect } from '@sveltejs/kit';
|
import { redirect } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
|
||||||
export const load = async ({ parent}) => {
|
export const load = async ({parent}) => {
|
||||||
|
|
||||||
const { user, apiKey, apiURL } = await parent();
|
const { user, apiKey, apiURL } = await parent();
|
||||||
|
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
redirect(303, '/');
|
redirect(303, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const getDashboard = async () => {
|
const getDashboard = async () => {
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
// Get cached data for the specific tickerID
|
||||||
const cachedData = getCache('', 'getDashboard');
|
const cachedData = getCache('', 'getDashboard');
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
return cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const response = await fetch(apiURL + '/dashboard-info', {
|
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');
|
setCache('', output, 'getDashboard');
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
return output;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make sure to return a promise
|
// Make sure to return a promise
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user