Initial commit 🚀

This commit is contained in:
Jonas Schmedtmann
2019-06-13 15:43:15 +01:00
commit 7f81af0ddf
1052 changed files with 2123177 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
/* eslint-disable */
import axios from 'axios';
import { showAlert } from './alerts';
export const login = async (email, password) => {
try {
const res = await axios({
method: 'POST',
url: 'http://127.0.0.1:3000/api/v1/users/login',
data: {
email,
password
}
});
if (res.data.status === 'success') {
showAlert('success', 'Logged in successfully!');
window.setTimeout(() => {
location.assign('/');
}, 1500);
}
} catch (err) {
showAlert('error', err.response.data.message);
}
};
export const logout = async () => {
try {
const res = await axios({
method: 'GET',
url: 'http://127.0.0.1:3000/api/v1/users/logout'
});
if ((res.data.status = 'success')) location.reload(true);
} catch (err) {
console.log(err.response);
showAlert('error', 'Error logging out! Try again.');
}
};