Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. $(function() {
  2. $('#form').submit((e) => {
  3. e.preventDefault();
  4. const email = $('.js-email-field').val();
  5. const password = $('.js-password-field').val();
  6.  
  7. $.ajax({
  8. url: '/api/login',
  9. method: 'POST',
  10. data: {
  11. email: email,
  12. password: password,
  13. },
  14. success: (response) => {
  15. sessionStorage.setItem('token', response.token);
  16. location.href = '/protected.html';
  17. },
  18. error: () => {
  19. renderError();
  20. }
  21. })
  22. })
  23. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement