-
-
Save tobyl/0caeeeaea535b90ba043bd0c73df0311 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const auth = { | |
login(payload) { | |
const email = payload.get('email'); | |
const password = payload.get('password'); | |
return fetch('/api/auth/jwt/token/', { | |
method: 'POST', | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json', | |
}, | |
body: JSON.stringify({ | |
email, | |
password, | |
}), | |
}) | |
.then(response => response.json()) | |
// .then(json => console.log(json)) | |
.catch(err => console.log(err)); | |
}, | |
getAuthToken() { | |
console.log('%c ** auth -> getAuthToken() **', 'color: green;'); | |
return localStorage.getItem('token'); | |
}, | |
setAuthToken(token) { | |
console.log('%c ** auth -> setAuthToken() **', 'color: green;'); | |
localStorage.setItem('token', token); | |
}, | |
removeAuthToken() { | |
console.log('%c ** auth -> removeAuthToken() **', 'color: green;'); | |
localStorage.removeItem('token'); | |
}, | |
authSuccess() { | |
console.log('%c ** auth -> authSuccess() **', 'color: green;'); | |
}, | |
}; | |
export default auth; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment