Guest User

Untitled

a guest
Sep 5th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. onSubmit() {
  2. this.loading = true;
  3.  
  4. const body = () => ({
  5. username: this.username,
  6. password: this.password,
  7. });
  8.  
  9. const processResponse = (response) => {
  10. this.loading = false;
  11.  
  12. if (response.data.success) {
  13. this.loggedUser = response.data.username;
  14. } else {
  15. this.error = 'Incorrect username/password';
  16. }
  17. };
  18.  
  19. const error = e => console.log(e);
  20.  
  21. axios
  22. .post(`${API}/api/login`, body())
  23. .then(processResponse)
  24. .catch(error);
  25. }
Add Comment
Please, Sign In to add comment