daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jun 21st, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top