Files
website/src/lib/utils.ts
bytedream 81d97380ca
All checks were successful
delpoy / build-and-deploy (push) Successful in 44s
make reported user nullable
2023-11-03 18:10:02 +01:00

19 lines
479 B
TypeScript

import { env } from '$env/dynamic/public';
export async function usernameSuggestions(
username: string
): Promise<{ name: string; value: string }[]> {
const response = await fetch(`${env.PUBLIC_BASE_PATH}/admin/users`, {
method: 'POST',
body: JSON.stringify({
limit: 6,
search: username,
slim: true
})
});
const json: { username: string; uuid: string }[] = await response.json();
return json.map((v) => {
return { name: v.username, value: v.uuid };
});
}