Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- $('#form').submit((e) => {
- e.preventDefault();
- const email = $('.js-email-field').val();
- const password = $('.js-password-field').val();
- $.ajax({
- url: '/api/login',
- method: 'POST',
- data: {
- email: email,
- password: password,
- },
- success: (response) => {
- sessionStorage.setItem('token', response.token);
- location.href = '/protected.html';
- },
- error: () => {
- renderError();
- }
- })
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement