Demo storing a token clientside for token based authentification (with jwt-auth)





Javascript code to store token in browser's local storage:
         $(function(){
            // see http://malsup.com/jquery/form/ for info about ajaxForm()
            $("#apiForm").ajaxForm({
                dataType:  'json',
                success: function(data) {
                    swal("API response:\n(token will be stored in local storage)\n"+JSON.stringify(data));
                    // store token in local storage
                    localStorage.setItem('token', data.token);
                },
                error: function(data) {
                    swal("Error:\n"+JSON.stringify(data));
                }
            });
        });
        

Contact

Location

Westerpark, Amsterdam, Netherlands

Send an e-mail