19 lines
479 B
TypeScript
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 };
|
|
});
|
|
}
|