Angular 2 observable subscribing twice executes call twice : <p><strong>Problem</strong><br>
I subscribe to an httpClient.get observable twice. However, this means that my call gets executed twice. Why is this?</p>

<p><strong>Proof</strong><br>
For every subscribe() I do, I get another line in the login page.</p>

<p><strong>Code (onSubmit() from login page button)</strong></p>

<pre><code>var httpHeaders = new HttpHeaders()
  .append("Authorization", 'Basic ' + btoa(this.username + ':' + this.password));

var observable = this.httpClient.get('api/version/secured', { headers: httpHeaders});
observable.subscribe(
  () =&gt; {
    console.log('First request completed');
  },
  (error: HttpErrorResponse) =&gt; {
    console.log('First request error');
  }
);
observable.subscribe(
  () =&gt; {
    console.log('Second request completed');
  },
  (error: HttpErrorResponse) =&gt; {
    console.log('Second request error');
  }
);
</code></pre>

<p><strong>Console</strong></p>

<pre><code>zone.js:2935 GET http://localhost:4200/api/version/secured 401 (Unauthorized)
login.component.ts:54 First request error
zone.js:2935 GET http://localhost:4200/api/version/secured 401 (Unauthorized)
login.component.ts:62 First request error
</code></pre>

<p><strong>Irrelevant background</strong><br>
I have a LogonService object which handles al my login functionality. It contains a boolean variable that shows whether I am logged in or not. Whenever I call the login function, it subscribes to the observable of the httpClient.get, to set the login variable to true or false. But the login function also returns the observable, which gets subscribed to. Took me some time to link the double request to the double subscription. If there is a better way of tracking the login than through a variable, let me know! I am trying to learn angular :)</p>
