Private
Public Access
Update obtenerGrupo.ts
This commit is contained in:
1 parent
141715ee0a
commit
05893bc462
1 file changed
+1
-8
@@ -1,15 +1,8 @@
|
||||
import { handleResponse } from '$lib/handleRespondeJSON';
|
||||
import type { Grupo } from '../../types';
|
||||
import { API_URL } from '../env';
|
||||
import { getToken } from './token';
|
||||
|
||||
async function handleResponse<T>(response: Response): Promise<T> {
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => ({ message: 'Error desconocido' }));
|
||||
throw new Error(error.error || 'Error en la petición');
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function obtenerGrupo(id: number, fetch?: Function): Promise<Grupo> {
|
||||
if (!fetch) fetch = window.fetch;
|
||||
const response = await fetch(`${API_URL}/grupos/${id}`, {
|
||||
|
||||
Reference in new issue
Block a user