Files
Repuestera/front/src/lib/hooks/repuestos/eliminarRepuesto.ts
T

21 lines
430 B
TypeScript

import { API_URL } from '$lib/env';
import { getToken } from '../token';
export async function eliminarRepuesto(id: number) {
try {
const req = await fetch(`${API_URL}/repuestos/${id}`, {
method: 'DELETE',
headers: {
Authorization: `Bearer ${getToken()}`
}
});
if (req.ok) {
return 'Ok';
}
const data = await req.json();
return data.error;
} catch {
return 'no se puso alcanzar el servidor';
}
}