mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-09 14:30:44 -03:00
checkeo si el username esta tomado
This commit is contained in:
16
src/lib/hooks/checkUsername.ts
Normal file
16
src/lib/hooks/checkUsername.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user