Lib: Move data fetching functions to library
This commit is contained in:
@ -1,21 +1,8 @@
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import type { User } from "$lib/schema";
|
||||
import { fetch_users } from "$lib/fetch";
|
||||
import type { PageLoad } from "../../$types";
|
||||
|
||||
export const load: PageLoad = async ({ fetch }) => {
|
||||
const fetch_users = async (): Promise<User[]> => {
|
||||
const users: User[] = await pb
|
||||
.collection("users")
|
||||
.getFullList({ fetch: fetch, sort: "+username" });
|
||||
|
||||
users.map((user: User) => {
|
||||
user.avatar_url = pb.files.getURL(user, user.avatar);
|
||||
});
|
||||
|
||||
return users;
|
||||
};
|
||||
|
||||
return {
|
||||
users: await fetch_users(),
|
||||
users: await fetch_users(fetch),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user