Rev 3365 |
|
Comparar con el anterior |
Ultima modificación |
Ver Log
|
Rev |
Autor |
Línea Nro. |
Línea |
3719 |
stevensc |
1 |
import { axios } from '@utils';
|
|
|
2 |
|
|
|
3 |
export const savePreferences = async (url, preferences) => {
|
|
|
4 |
const formData = new FormData();
|
|
|
5 |
Object.entries(preferences).forEach(([key, value]) => formData.append(key, value));
|
|
|
6 |
const response = await axios.post(url, formData);
|
|
|
7 |
const { data, success } = response.data;
|
|
|
8 |
if (!success) {
|
|
|
9 |
const errMsg = typeof data === 'string' ? data : 'Error al guardar el progreso del hábito';
|
|
|
10 |
throw new Error(errMsg);
|
|
|
11 |
}
|
|
|
12 |
return data;
|
|
|
13 |
};
|