mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-20 16:17:32 -03:00
hecha la pagina de busqueda
This commit is contained in:
18
src/lib/hooks/busquedaUsuarios.ts
Normal file
18
src/lib/hooks/busquedaUsuarios.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { apiBase } from '@/stores/url';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export async function busquedaUsuarios(username: string) {
|
||||
if (!username) return null;
|
||||
try {
|
||||
const req = await fetch(`${get(apiBase)}/api/users/search?q=${username}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
if (req.ok) {
|
||||
let data = await req.json();
|
||||
return data;
|
||||
}
|
||||
return [];
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user