title: How to form a authorization CURL request in AJAX?
body: <p>I have the following CURL request requiring a JWT token for accessing a protected route in express.js. This request is working fine.</p>
  
  <pre><code>curl --request GET \
    --url http://localhost:3001/api/v1/protected/random-quote \
    --header 'Authorization: Bearer eyJ0xxxxQ.NLNOn1caBeGFlPRnsSjLDIKFggMItcm-dl5PKOjlLxs' \
    --header 'Content-Type: application/json'
  </code></pre>
  
  <p>How do I formulate the corresponding AJAX request? </p>
  
  <pre><code>&lt;script&gt;
  var id_tok = Cookies.get('id_token');
  var access_tok =   Cookies.get('access_token');
  
  var headersOb = 'Authorization: Bearer ' + access_tok;
  
  $.ajax({
    type: 'GET',
    url:   'http://localhost:3001/api/v1/protected/random-quote',
   headers: headersOb,
   contentType: 'application/json',
   dataType: 'json'
  }).done(function(data) {
   console.log(data);
   console.log('data called success');
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>With the above AJAX request I get the following error:</p>
  
  <pre><code>VM9599 jquery.min.js:3049 GET   http://localhost:3001/api/v1/protected/random-quote 401 (Unauthorized)
  </code></pre>