Private
Public Access
17 lines
539 B
TypeScript
17 lines
539 B
TypeScript
import { handleResponse } from '$lib/handleRespondeJSON';
|
|
import type { Grupo } from '../../types';
|
|
import { API_URL } from '../env';
|
|
import { getToken } from './token';
|
|
|
|
// Se usa en la parte de /usuarios
|
|
export async function obtenerGruposDeUsuario(dto: {
|
|
usuario_id: number;
|
|
}): Promise<Grupo[] | string> {
|
|
if (!dto.usuario_id) return 'Falta datos';
|
|
const response = await fetch(`${API_URL}/usuarios/${dto.usuario_id}/grupos`, {
|
|
headers: { Authorization: `Bearer ${getToken()}` }
|
|
});
|
|
|
|
return handleResponse<Grupo[]>(response);
|
|
}
|