title: HTTP GET 401 Authorization Required error in angular 6
body: <p>I'm trying trying to connect with AWS API.I have API username and password for basic authentication and trying to get some data list by GET method.
  It's working fine with postment.But I'm getting 401 error when I do it in angular code.</p>
  
  <pre><code>401 Authorization Required error
  </code></pre>
  
  <p>My code is like below,</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>  public getSavedIntents(): Observable&lt;any&gt; {
  
      const url = `${this.API_AWS_URL}intent`;  
      const apiUsername = "frontend-dev";
      const apiPassword = "Wo8aedfgsdfg444445454aw5quae5a"; 
      
      var reqHeader = new HttpHeaders();
      reqHeader.append("Content-Type", "application/json");
      reqHeader.append("Access-Control-Allow-Origin", "*");
      reqHeader.append("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
      reqHeader.append("Authorization", "Basic " + btoa(apiUsername + ":" + apiPassword));
     
      return this.http
        .post&lt;any&gt;(url, { headers: reqHeader })
        .pipe(
          catchError(err =&gt; {
            throw err;
          })
        );
    }</code></pre>
  </div>
  </div>
  </p>