title: How to call multiple API and subscribe in angular 6?
body: <p>In my app, to call all the <code>POST</code> request I have used a <code>service</code>.</p>
  
  <p>When I get a <strong>specific</strong> code <strong>(E.x : 401)</strong> from the server, I call an API to fetch new token.</p>
  
  <p>Till the another token is received, if there's any other API call from, I store all those requests in an array. It may be <strong>n</strong> requests. For now assume there are 3 API call while the call for newToken API is in progress.</p>
  
  <p>Once I get a new token I have to pass that in all the subsequent API's. Now I have to execute all the pending API requests and give data to their respective calls. </p>
  
  <p><strong>Code Example :</strong></p>
  
  <p><strong>api.service.ts</strong></p>
  
  <pre><code>POST(URL , param){
     return new Observable&lt;any&gt;(observer =&gt; {
  
    let headers = new HttpHeaders({
      'Content-Type': 'Content-Type': 'application/json'
    });
  
    let options = {
      headers: headers
    };
  
    this.http.post(URL, param, options)
          .subscribe(data =&gt; {
            var apiRes: any = data;                                       
            this.inValidSession();
            observer.next();
            observer.complete();              
    }
    ......
  
    //  For execute pending request I have set this 
  
    for (let i = 0; i &lt; this.queue.length; i++) {                          
          this.REPOST(this.queue[i].param, this.queue[i].url).subscribe((queueResponse) =&gt; {             
            observer.next(queueResponse);
            observer.complete();
            this.queue.shift();                      
         });
     }
  }
  </code></pre>
  
  <p><strong>user.component.ts</strong></p>
  
  <pre><code>ngOnInit(){
      this.getUserData();        
      this.getProductData();
  }
  
  getUserData(){
     this.apiService.post({},'/apiName').subscribe((response) =&gt; {
         console.log(response);
     })
  }
  
  getProductData(){
     this.apiService.post({},'/apiName2').subscribe((response) =&gt; {
         console.log(response);
     })
  }
  </code></pre>
  
  <p>Issue is , when I execute all pending API's, I get data in the console. But not <code>subscribe</code> from service file to respective <code>.ts</code> file's function.</p>
  
  <p>Note: I get subscribed data in only one function not each. In other words, I get both API res in <code>getProductData()</code> function. I don't know why.</p>
  
  <p>Please help me if any one has solution. </p>