import type { PageLoad } from './$types';
import { errorMsg } from '../../../helpers';
import { server } from '../../../helpers';
export const load: PageLoad = async ({ url, fetch, params }) => {
const from_ = parseInt(url.searchParams.get('from') || '0') || 0;
const to = parseInt(url.searchParams.get('to') || '0') || 0;
const resp = await fetch(
from_ && to
? `${server}/api/change/${params.user}/${params.repo}/list?from=${from_}&to=${to}`
: from_
? `${server}/api/change/${params.user}/${params.repo}/list?from=${from_}`
: to
? `${server}/api/change/${params.user}/${params.repo}/list?to=${to}`
: `${server}/api/change/${params.user}/${params.repo}/list`
);
if (resp.status == 200) {
return await resp.json();
} else {
const y = await resp.json();
errorMsg(resp.status, y);
}
};