title: How to do HTTP Basic Authentication in ionic
body: <p>I am totally new to ionic. In my project, the API both have a basic authentication. The API then run OK on Postman, but don't know how to do it on ionic. I have research for several articles but they need a lot of step to follow after some steps I get lost.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>app.controller('MainViewController', function ($scope, $http) {
    $http({
      method:"GET",
      url:"my_url"
    }).then(function(categories){
      console.log(categories);
    });
  });
  </code></pre>
  
  <p>I got the error on console: </p>
  
  <blockquote>
    <p>GET "my_url" 401 (Unauthorized)</p>
  </blockquote>
  
  <p>Here is the setup on Postman:
  <a href="https://i.stack.imgur.com/NPP95.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NPP95.png" alt="Postman setup authorization"></a></p>
  
  <p>And the header then:
  <a href="https://i.stack.imgur.com/ErAQi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ErAQi.png" alt="enter image description here"></a>
  Do you know what is the proper way to do this on ionic</p>