Private
Public Access
falla
This commit is contained in:
1 parent
6c0e44cb45
commit
90e76d4963
11 files changed
+112
-38
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { API_URL } from '$lib/env';
|
||||
import { getToken } from '../token';
|
||||
|
||||
export async function obtenerRepuestos(fetch2?: Function) {
|
||||
const fetchfn = fetch2 ? fetch2 : fetch;
|
||||
try {
|
||||
const req = await fetchfn(`${API_URL}/repuestos`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${getToken()}`
|
||||
}
|
||||
});
|
||||
const data = await req.json();
|
||||
if (req.ok) {
|
||||
return data;
|
||||
}
|
||||
return data.error;
|
||||
} catch {
|
||||
return 'no se puso alcanzar el servidor';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user