1

I create a user and now I want to login the user after this operation. I was using toPromise() but now I just want to use observables:

    return this.httpClient.post('/user', user)
                          .map(response => response.json() as User)
                          .catch(this.handleError);

With promises I could do this

return this.create(data)
           .then(function(user: User) {
              return self.login(user.email, user.password);
           })
           .then(function(resp: loginStuff) {
              // set session
           })

How can I chain with observables?

eko
  • 39,722
  • 10
  • 72
  • 98
el_pup_le
  • 11,711
  • 26
  • 85
  • 142
  • 5
    Possible duplicate of [Chaining RxJS Observables from http data in Angular2 with TypeScript](https://stackoverflow.com/questions/35268482/chaining-rxjs-observables-from-http-data-in-angular2-with-typescript) – Vivek Doshi Aug 01 '17 at 05:16
  • what are you expecting? – manish kumar Aug 01 '17 at 05:21
  • 1
    Not sure what you want. There is 'do' https://www.learnrxjs.io/operators/utility/do.html and 'Observable.fromPromise' https://stackoverflow.com/a/39319314/495157 – JGFMK Aug 01 '17 at 05:35

0 Answers0