title: Angular 4 - chaining subscribe
body: <p>I am calling a webservice from Angular 4 code and subscribing to the response. When the response comes, I need to parse it and using the parsed information call another webservice (and then subscribe to the response once again). </p>
  
  <p>How can I achieve this chaining using Rxjs subscribe.</p>
  
  <p>In the below code, I am calling a customer web service to get his pin code. When I get that, only then I need to call the 2nd rest service with pin code as an input.</p>
  
  <pre><code>fetchCoordinates() {
  
      this.myService.get('http://&lt;server&gt;:&lt;port&gt;/customer')
        .subscribe(
        (response: Response) =&gt; {
  
          let pinUrl = JSON.parse(response.text()).items[0].pin;
          // Take the output from first rest call, and pass it to the second call
          this.myService.get(pinUrl).subscribe(
            (response: Response) =&gt; {
               console.log(response.text()); 
            }
          )
        },
        (error) =&gt; console.log('Error ' + error)
        )
    }
  </code></pre>
  
  <p>Is this the right way of chaining subscribe? I need to do one more web service after results of 2nd services comes back. It would be nesting the code block even further.</p>