Private
Public Access
wip: skeleton de la funcionalidad falta arreglar un bug
This commit is contained in:
1 parent
266365ae0f
commit
f9cf001fca
9 files changed
+270
-1
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { API_URL } from '$lib/env';
|
||||
import type { ActualizarRepuestoDto } from '../../../types';
|
||||
import { getToken } from '../token';
|
||||
|
||||
export async function actualizarRepuesto(repuesto: ActualizarRepuestoDto) {
|
||||
try {
|
||||
const req = await fetch(`${API_URL}/repuestos/${repuesto.id || 0}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${getToken()}`
|
||||
},
|
||||
body: JSON.stringify((({ id, ...rest }) => rest)(repuesto))
|
||||
});
|
||||
|
||||
if (req.ok) {
|
||||
return 'Ok';
|
||||
}
|
||||
const data = await req.json();
|
||||
return data.error;
|
||||
} catch {
|
||||
return 'no se puso alcanzar el servidor';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user