title: Angular 5 HTTPClient Basic Authorization not working
body: <p>I'am trying to implement basic authorization in Angular 5. I'm using HttpClient and HttpHeaders. I'm trying to connect to a tomcat server with a REST service.</p>
  
  <p>This code is in my login function.</p>
  
  <pre><code>this.storage.set('credentials', credentials);
  return new Promise((resolve, reject) =&gt; {
      let headers = new HttpHeaders();
      //btoa permet d'encoder le username et le mot de passe en base64
      headers = headers.append("Authorization", "Basic " + btoa(credentials.username + ':' + credentials.password));
      headers = headers.append("Content-Type", "application/x-www-form-urlencoded");
  
      //utilisation de stateless pour ne créer qu'une session http et ne pas créer une session par requete
      this.http.post(apiUrl+'ADUser', JSON.stringify({l: credentials.username, p: credentials.password}),{ headers:headers })
        .subscribe(res =&gt; {
          resolve((res: Response) =&gt; res.json());
        }, (err) =&gt; {
          console.log(err);
          reject();
          let alert = this.alertCtrl.create({
          title: 'L\'authentification a échoué',
          subTitle: 'Le nom d\'utilisateur ou le mot de passe est incorrect',
          buttons: ['OK']
        });
        alert.present();
        });
  });    
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/9aN02.png" rel="nofollow noreferrer">This is from the Chrome tools Network tab</a></p>
  
  <p>After looking on the forums and on this site, I have not found a solution to my problem.
  Could someone please help me with this problem ?</p>
  
  <p>Thank you in advance for your response and the time spent helping me</p>