title: http request in angular 2 getting called twice
body: <p>I know this question is avialable on the stackover flow and i belive me i had gone through it. Based , on that i found that there is no problem in my code. Although my rest api are getting called twice.</p>
  
  <p>My Code snippet looks like:</p>
  
  <p><strong>Component:</strong></p>
  
  <pre><code>    export class Component  {
  
          constructor(private _nService: NService) {
              this.categoryList = this._nService.getCategories();
              this.getMessage();
          }
  
       getMessage() {
          console.log('inside getMessagecomponent');
          this._nService.getNotifications().subscribe(notifications =&gt; {
              console.log('Calling Service...');
          });
  
       }
      }
  </code></pre>
  
  <p><strong>Service:</strong></p>
  
  <pre><code>@Injectable()
  export class NService {
  
      constructor(private http: Http) { }
  
     getNotifications() {
          console.log('inside getNotification service');      
          return this.http.get(URL)
              .map((res: Response) =&gt; res.json());
      }
  
  }
  </code></pre>
  
  <p>I have put the console.log in component and service just to analyze that whether the method is called from some other places or not or getting called twice or not.</p>
  
  <p>I found the console.log in component and service are getting called only once.But, my rest api are calling twice by this request.</p>
  
  <ul>
  <li>I have tried .share() but its not working in my case.</li>
  <li>Also i tried to unsubscribe my call its also not working</li>
  </ul>
  
  <p>Sequence in which my console.log are getting displayed:</p>
  
  <ul>
  <li>inside getMessagecomponent component</li>
  <li>inside getNotification service</li>
  <li>Calling Service...</li>
  </ul>
  
  <p>PS: This is happing with all the apis in my project. </p>
  
  <p><a href="https://i.stack.imgur.com/CKgpe.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CKgpe.jpg" alt="enter image description here"></a></p>
  
  <p>Headers:</p>
  
  <pre><code>Request 1:
  ----------------
  
  Access-Control-Allow-Credentials:true
  Access-Control-Allow-Headers:Content-Type, Accept, X-Requested-With, remember-me, x-dd-cust, x-dd-apitoken
  Access-Control-Allow-Methods:POST, GET, PUT, OPTIONS, DELETE
  Access-Control-Allow-Origin:http://localhost:8425
  Access-Control-Max-Age:3600
  Cache-Control:no-cache, no-store, max-age=0, must-revalidate
  Content-Type:application/json;charset=UTF-8
  Date:Mon, 20 Mar 2017 07:00:40 GMT
  Expires:0
  Pragma:no-cache
  Transfer-Encoding:chunked
  X-Application-Context:application:dev:8085
  X-Content-Type-Options:nosniff
  X-Frame-Options:DENY
  X-XSS-Protection:1; mode=block
  
  Response 1:
  ---------------
  
  Accept:application/json, text/plain, */*
  Accept-Encoding:gzip, deflate, sdch, br
  Accept-Language:en-US,en;q=0.8
  Cache-Control:max-age=0
  Connection:keep-alive
  Content-Type:application/json
  Host:localhost:8085
  Origin:http://localhost:8425
  Referer:http://localhost:8425/dashboard
  User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
  x-dd-apitoken:TOKEN
  x-dd-cust:name
  
  Request 2:
  --------------
  
  Access-Control-Allow-Credentials:true
  Access-Control-Allow-Headers:Content-Type, Accept, X-Requested-With, remember-me, x-dd-cust, x-dd-apitoken
  Access-Control-Allow-Methods:POST, GET, PUT, OPTIONS, DELETE
  Access-Control-Allow-Origin:http://localhost:8425
  Access-Control-Max-Age:3600
  Cache-Control:no-cache, no-store, max-age=0, must-revalidate
  Content-Type:application/json;charset=UTF-8
  Date:Mon, 20 Mar 2017 07:00:40 GMT
  Expires:0
  Pragma:no-cache
  Transfer-Encoding:chunked
  X-Application-Context:application:dev:8085
  X-Content-Type-Options:nosniff
  X-Frame-Options:DENY
  X-XSS-Protection:1; mode=block
  
  Resposne 2:
  ------------
  
  Accept:application/json, text/plain, */*
  Accept-Encoding:gzip, deflate, sdch, br
  Accept-Language:en-US,en;q=0.8
  Cache-Control:max-age=0
  Connection:keep-alive
  Content-Type:application/json
  Host:localhost:8085
  Origin:http://localhost:8425
  Referer:http://localhost:8425/dashboard
  User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
  x-dd-dd:TOKEN
  x-dd-cust:name
  </code></pre>
  
  <blockquote>
    <p>UPDATE</p>
  </blockquote>
  
  <p>I found in the developer console its not OPTION request as i can see 2 GET request in the network tab.</p>