mirror of
https://github.com/ProjectSegfault/website.git
synced 2024-11-01 08:23:07 +05:30
27 lines
511 B
TypeScript
27 lines
511 B
TypeScript
import type { PageServerLoad } from "./$types";
|
|
|
|
export const load = (async ({ fetch }) => {
|
|
const meta = {
|
|
title: "Pubnix"
|
|
};
|
|
|
|
try {
|
|
const request = await fetch("https://publapi.p.projectsegfau.lt/users");
|
|
|
|
if (request.ok) {
|
|
return {
|
|
users: await request.json(),
|
|
...meta
|
|
};
|
|
} else {
|
|
return {
|
|
error: true,
|
|
message: "Error: " + request.status,
|
|
...meta
|
|
};
|
|
}
|
|
} catch (err) {
|
|
return { error: true, message: "Error: " + err, ...meta };
|
|
}
|
|
}) satisfies PageServerLoad;
|