jQuery ajax with authorization token bearer with jwt

jQuery -- Posted on Feb. 17, 2024

Example of jquery ajax call with authorization bearer token 

              
                $.when($.ajax({
        url: 'url',
        method:  'get',
        datatype: 'json',
        headers: {"Authorization": "Bearer " + localStorage.getItem('token')}

      })).then(function( response, textStatus, jqXHR ) {
      console.info(response);
      var obj = response;
      console.info(obj)
      
    }).catch(function(err){
      $.each(err.responseJSON, function(index, value){
        console.info(index, value);
    })
})
                  
   
            

Related Posts