frontend_adaptive_learning/src/roles/user/setting/services/SettingService.jsx
2024-12-05 15:31:12 +07:00

41 lines
895 B
JavaScript

import axiosInstance from '../../../../utils/axiosInstance';
const config = {
headers: {
Authorization: localStorage.getItem('token')
}
};
const fetchProfile = async () => {
try {
const response = await axiosInstance.get(`/getMe`, config);
return response.data;
} catch (error) {
throw error;
}
};
const updateProfile = async (id, formData) => {
try {
const response = await axiosInstance.put(`/user/update/${id}`, formData);
return response.data;
} catch (error) {
throw error;
}
};
const updatePassword = async (userId, passwordData) => {
try {
const response = await axiosInstance.put(`/user/update/password/${userId}`, passwordData);
return response.data;
} catch (error) {
throw error;
}
};
export default {
fetchProfile,
updateProfile,
updatePassword
};