title: Angular 5 - Subscribing an Observable after a callback function(subscribe cannot read property subscribe of undefined)
body: <p>I have to return observable response to my parent component after callback function executed.</p>
  
  <p>if i put <strong>return this._httpService.insertRMS(url, body);</strong> without callback, i able to get the response whatever success or error.</p>
  
  <p>As i understood able to consume subscribe, only in observable type of response. is any other is available to consume observable response after callback function executed.</p>
  
  <p>I have written <strong>getParcelInfo</strong> function inside callback function, due to duplicate avoid, since it needs so many times for other functionality<a href="https://i.stack.imgur.com/9AiCH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9AiCH.png" alt="enter image description here"></a></p>
  
  <p>comp1.ts</p>
  
  <pre><code>parcelinfo(){
  this._pmsToRMSService.createOrderDelivery(351).subscribe(//Error
    response =&gt; {
      alert("success");
    },
    error =&gt; {
      alert("error");
    });
  }
  </code></pre>
  
  <p>comp2.ts</p>
  
  <pre><code>@Injectable()
  export class PMSToRMSService {
  
  private getParcelInfo(parcelid, callback): any {
  
      let url = serviceAPI.urlParcel + parcelid;
      this._httpService.getData(url).subscribe(
          response =&gt; {
              callback(response);
          },
          error =&gt; {
              callback(error);
          });
  }
  
  public createOrderDelivery(parcelid: number): Observable&lt;any&gt; {
  
     return this.getParcelInfo(parcelid, pmsResponse =&gt; {          
  
                  let body = pmsResponse;
  
                  let url = serviceAPI.urlRMSCreateOrder;
  
                  return this._httpService.insertRMS(url, body);//Output Need
  });
  }
  </code></pre>
  
  <p>}</p>