title: HttpClientModule fires two requests and one of them doesn't have the authentication header. What am I doing wrong?
body: <p>I'm working with HttpClientModule from angular 4.3 on Ionic 3. My application communicates with a Django server that asks for an authentication header that is being sent by an interceptor. The problem I'm facing is that when I ask HttpClientModule to perform the get request, it sends two requests. One with the authentication header, that is not responded, and other with no authentication header. Can anyone help me? I don't know what I am doing wrong :(</p>
  
  <p>Here's what I see in the Web Inspector:</p>
  
  <p><a href="https://i.stack.imgur.com/o9f2l.png" rel="nofollow noreferrer">First request sent</a></p>
  
  <p><a href="https://i.stack.imgur.com/QAfDq.png" rel="nofollow noreferrer">Second request sent</a></p>
  
  <p>Here's my Provider:</p>
  
  <pre><code>import { HttpClient, HttpErrorResponse } from '@angular/common/http';
  import { Injectable } from '@angular/core';
  import { LoadingController, AlertController } from 'ionic-angular';
  
  @Injectable()
  export class RestProvider {
  
      private url = "http://10.0.1.50:8000/";
  
      constructor(public http: HttpClient, private alertCtrl: AlertController, private loadingCtrl: LoadingController) { }
  
      getDisp(){
          return new Promise(resolve =&gt; {
              this.http.get(this.url+'api/Dispositivos').subscribe(data =&gt; {
                  console.log(data);
                  resolve(data);
              }, (err: HttpErrorResponse) =&gt; {
                  if (err instanceof ErrorEvent){
                      let alert = this.alertCtrl.create({
                          title: 'Algo deu errado :(',
                          subTitle: 'Parece que há algo errado com a sua conexão. Tente novamente',
                          buttons: ['OK']
                      });
                      alert.present();
                  } else {
                      let alert = this.alertCtrl.create({
                          title: 'Algo deu errado :(',
                          subTitle: 'Desculpe, parece que nossos servidores estão com problemas. Tente novamente em alguns minutos',
                          buttons: ['OK']
                      });
                      alert.present();
                  }
              });
          });
      }
  </code></pre>
  
  <p>}</p>
  
  <p>And here's my interceptor:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
  import { Observable } from 'rxjs/Observable';
  
  
  
  @Injectable()
  export class TokenInterceptor implements HttpInterceptor {
  
      public credenciais: any;
  
      intercept(request: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; {
  
          if (localStorage.credenciais != null) {
              this.credenciais = JSON.parse(localStorage.credenciais)
              request = request.clone({
                  setHeaders: {
                      Authorization: 'Token '+this.credenciais.token
                  }
              });
          }
          return next.handle(request);
      }
  }
  </code></pre>
  
  <p>Here's the function I use to call the Provider:</p>
  
  <pre><code>import { NavController } from 'ionic-angular';
  import { LoginPage } from "../../pages/login/login";
  import { RestProvider } from '../../providers/rest/rest';
  
  [...]
  
  constructor(public navCtrl: NavController, public restProvider: RestProvider) {}
  
  [...]
  
  carregaDisp(){
      return new Promise(resolve =&gt; {
          this.restProvider.getDisp().then(data =&gt; {
              if (data == null) {
                  this.navCtrl.setRoot(LoginPage);
              } else {
                  this.dispositivo = data;
                  this.atualizaStatus().then(() =&gt; {
                      console.log(data);
                      resolve();
                  });
              }
          });
      });
  }
  </code></pre>
  
  <p>I don't know what I am doing wrong and I've Googled everything I could think of. Sorry if it's a beginners mistake, but I can't find it's solution :(</p>