checkeo si el username esta tomado

This commit is contained in:
2025-12-03 17:11:12 -03:00
parent 4f4f2fc9dd
commit 89cc2cbaf6
3 changed files with 53 additions and 5 deletions

View File

@@ -0,0 +1,16 @@
import { apiBase } from "@/stores/url";
import { get } from "svelte/store";
export async function checkUsername(username: string) {
try {
const req = await fetch(`${get(apiBase)}/api/users/check-username/${username}`, {
method: "GET"
});
if (req.ok){
return (await req.json()).available;
}
return false;
} catch {
return false;
}
}