Question: I'm trying to do the following with observables and I can't figure out what the best way would be to do it:

I'm calling a login endpoint using http. This service will return a token. I want to perform 2 different actions from 2 different points within the APP sequentially: when http resolves I need to store the provided token and then show a message. I tried the following:

```
return this.http.get(this.config.getApi('login'), params)
           .map(response => response.json())
           .do((data) => {
               // Store token here
               // If it fails, throw error
               // Tried Observable.throw here but the subscriber doesn't get it.
            }).subscribe(
               (data) => {
                  // Everything went fine
                },
               () => {
                  // Either the http request failed or 
                 // the process of storing the token threw an error.
            }
       );

```

Unfortunately, the subscribers to the returned observable never get error unless the http call fails. What operator should I use instead of do?

Thanks.

Answer: 
You should be `subscribing` to access the response

```
this.http.get(this.config.getApi('login'), params)
                .map(response => response.json())
                .subscribe(data=>{
                     console.log(data);
       });

```
Maybe something like this?

```
import { isDevMode } from '@angular/core';
import { _throw } from 'rxjs/observable/throw';

return this.http.get(this.config.getApi('login'), params)
.map(r => r.json())
.do(data => {
  this.token = data; //an instance variable defined in your service class
  if(isDevMode()) console.log(data) // display log only in devMode (why would you want to log something in console in production?! :D)
})
.catch(error => _throw(JSON.stringify(error));

```

Ofc you need to invoke this method from outside (component,guard,etc) so that the http request is executed