Fakultas Ilmu Komputer UI

Commit 71c6af8a authored by Jonathan Chandra's avatar Jonathan Chandra
Browse files

edit auth.service.js

parent ec135798
......@@ -2,31 +2,8 @@ import axios from 'axios';
import { API_URL } from '../../config/keys';
class AuthService {
async login(email, password) {
const response = await axios.post(`${API_URL}/users/signin`, {
email,
password,
});
if (response?.data?.token)
localStorage.setItem('user', JSON.stringify(response.data));
return response;
}
logout() {
localStorage.removeItem('user');
localStorage.removeItem('callback');
}
async register(username, email, password) {
const response = await axios.post(`${API_URL}/users/signup`, {
user: {
username,
email,
password,
},
});
await this.login(email, password);
return response;
}
getCurrentUser() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment