mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-06 14:00:43 -03:00
feat: borrar usaurios
This commit is contained in:
21
src/lib/hooks/borrarUsuario.ts
Normal file
21
src/lib/hooks/borrarUsuario.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { apiBase } from '@/stores/url';
|
||||
import { sesionStore } from '@/stores/usuario';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export async function borrarUsuario(id: string) {
|
||||
try {
|
||||
const req = await fetch(`${get(apiBase)}/api/users/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
|
||||
}
|
||||
});
|
||||
|
||||
if (req.ok) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user