Files
Jonas Schmedtmann 7f81af0ddf Initial commit 🚀
2019-06-13 15:43:15 +01:00

26 lines
634 B
JavaScript

/* eslint-disable */
import axios from 'axios';
import { showAlert } from './alerts';
// type is either 'password' or 'data'
export const updateSettings = async (data, type) => {
try {
const url =
type === 'password'
? 'http://127.0.0.1:3000/api/v1/users/updateMyPassword'
: 'http://127.0.0.1:3000/api/v1/users/updateMe';
const res = await axios({
method: 'PATCH',
url,
data
});
if (res.data.status === 'success') {
showAlert('success', `${type.toUpperCase()} updated successfully!`);
}
} catch (err) {
showAlert('error', err.response.data.message);
}
};