Angular 2 / rxjs chaining HTTP calls I have a registration form. Step 1 user creates an account. As user creates an account I need to authenticate user with the created account. 

in my account.service.ts I have following. 

Is this the best way to handle this? and how can improve this to handle errors from 2 different http calls?

  public createAccount(reg: CreateUserRequestModel): Observable&lt;any&gt; {
    return this.apiService.post('api/register/account', reg)
      .flatMap(()=&gt;{
        return this.authenticationService.authenticate(reg.emailAddress, reg.password)
      }).map((response)=&gt;{
        return response.json()
      })
      .catch((error: any) =&gt; {
        return Observable.throw(error.json());
      });
  }
public createAccount(registrationRequest: CreateUserRequestModel): Observable&lt;SomeType&gt; {
  return this.apiService.post('api/register/account', registrationRequest)
    .flatMap(() =&gt; this.authenticationService.authenticate(registrationRequest.emailAddress, registrationRequest.password))
    .map(response =&gt; &lt;SomeType&gt;response.json())
    .catch(error =&gt; Observable.throw(error.json()));
}



@Tushar made a good point on code compactness, which can be applied to all arrow functions in the code.
TypeScript is about types. Try to not use any in return type definitions. Do define some return type and cast the result to it (see SomeType).
I'm not sure if you really want to do .catch(error =&gt; Observable.throw(error.json())) where it happens now or move it to the consumers side (e.g. .subscribe(() =&gt; {...}, error =&gt; this.handle(error))
reg is a bad name. Spell things out.