Private
Public Access
18 lines
502 B
TypeScript
18 lines
502 B
TypeScript
import { API_URL } from '$lib/env';
|
|
import { getToken } from '../token';
|
|
|
|
export async function obtenerFacturas(fetch2?: Function) {
|
|
const fetchfn = fetch2 ? fetch2 : fetch;
|
|
try {
|
|
const req = await fetchfn(`${API_URL}/facturas/`, {
|
|
method: 'GET',
|
|
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${getToken()}` }
|
|
});
|
|
const data = await req.json();
|
|
if (req.ok) return data;
|
|
return data.error ?? 'error';
|
|
} catch {
|
|
return 'no se pudo alcanzar el servidor';
|
|
}
|
|
}
|