Currently I'm working through some tutorials on using web tokens, and I got the back end working (ie when authentication is successful it sends back a signed token). However, I'm having trouble seeing how to actually store it locally in storage, I keep getting "out of memory exception".
form(id='creds' role='form' method='post')
.form-group
label.sr-only(for='email') Username:
input.form-control(id='email' type='text', name='email', placeholder='Email')
.form-group
label.sr-only(for='password') Password:
input.form-control(id='password' type='password', name='password', placeholder='Password')
.text-center
button.btn.btn-primary.btn-block(type='submit') Submit
p
script.
$(document).ready(function() {
$('#creds').on('submit', function() {
var creds = {
email: $('#email').val(),
password: $('#password').val()
}
var jqxhr = $.post('/login', creds, function(data) {
window.sessionStorage.token = data.token;
alert('success!');
});
jqxhr.fail(function() {
$('#password').val('');
alert('failure!');
});
});
});
What am I doing wrong?
Thanks