title: AngularJS and an external API - getting it to work like PostMan
body: <p>I've been trying to access the sqwiggle API inside my Angular app and was testing it using <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;ved=0CCgQFjAA&amp;url=https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en&amp;ei=zrj0UsqROKLNygPRg4KYAw&amp;usg=AFQjCNHaecLwAKk91gpdCY_y1x_ViIrHwQ&amp;sig2=SCupzp8fyscQNOgcA4yGeA&amp;bvm=bv.60799247,d.bGQ" rel="nofollow" title="Postman">Postman</a>. All seems to work fine. I define a Basic Auth header, do a GET request to the messages endpoint and I get a nice response. These are the request headers (from Postman):</p>
  
  <pre><code>Request URL:https://api.sqwiggle.com/messages
  Request Method:GET
  Status Code:200 OK
  Request Headersview source
  Accept:*/*
  Accept-Encoding:gzip,deflate,sdch
  Accept-Language:en-US,en;q=0.8,nl;q=0.6
  Authorization:Basic [secret]
  Cache-Control:no-cache
  Connection:keep-alive
  Host:api.sqwiggle.com
  User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.70 Safari/537.36
  </code></pre>
  
  <p>Now in my AngularJS app, I want to do the same:</p>
  
  <pre><code>$http.get('https://api.sqwiggle.com/messages', {
      headers: {
          Authorization: 'Basic [secret]'
      }
  }).success(function(e) {
      alert(e);
  });
  </code></pre>
  
  <p>But this results in the following request headers:</p>
  
  <pre><code>Request URL:https://api.sqwiggle.com/messages
  Request Method:OPTIONS
  Status Code:404 Not Found
  Request Headersview source
  Accept:*/*
  Accept-Encoding:gzip,deflate,sdch
  Accept-Language:en-US,en;q=0.8,nl;q=0.6
  Access-Control-Request-Headers:accept, authorization
  Access-Control-Request-Method:GET
  Connection:keep-alive
  Host:api.sqwiggle.com
  Origin:http://localhost:8888
  Referer:http://localhost:8888/
  User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53
  </code></pre>
  
  <p>Given the fact that Postman uses JS to get the data from the API, it should be possible in AngularJS too, or am I missing something here? Why is Angular transforming the GET in an OPTIONS request and why is it not adding the Authorization header? </p>
  
  <p>Thanks for your help</p>