3719 |
stevensc |
1 |
import { axios } from '@utils';
|
|
|
2 |
|
|
|
3 |
export const saveValue = async (url, value) => {
|
|
|
4 |
const formData = new FormData();
|
|
|
5 |
Object.entries(value).forEach(([key, value]) => formData.append(key, value));
|
|
|
6 |
const response = await axios.post(url, formData);
|
|
|
7 |
const { data, message, success } = response.data;
|
|
|
8 |
if (!success) throw new Error('Error al guardar el valuea');
|
|
|
9 |
return { data, message };
|
|
|
10 |
};
|
|
|
11 |
|
|
|
12 |
export const editValue = async (url, value) => {
|
|
|
13 |
const formData = new FormData();
|
|
|
14 |
Object.entries(value).forEach(([key, value]) => formData.append(key, value));
|
|
|
15 |
const response = await axios.post(url, formData);
|
|
|
16 |
const { data, message, success } = response.data;
|
|
|
17 |
if (!success) throw new Error('Error al editar el valuea');
|
|
|
18 |
return { data, message };
|
|
|
19 |
};
|
|
|
20 |
|
|
|
21 |
export const deleteValue = async (url) => {
|
|
|
22 |
const response = await axios.post(url);
|
|
|
23 |
const { data, success } = response.data;
|
|
|
24 |
if (!success) throw new Error('Error al eliminar el valuea');
|
|
|
25 |
return data;
|
|
|
26 |
};
|