title: Retrieve the value of ionic2 storage and attach to a value fails
body: <p>I have a custom http service that attaches an access token to every request and i would like to use an access token from ionic2 storage value</p>
  
  <p>This is the code from my two previous questions</p>
  
  <p>So in the httpclient service i have</p>
  
  <pre><code>@Injectable()
  export class HttpClient {
     authtoken: string;
     storage: Storage;
  
  constructor(private http: Http, storage: Storage, private _authService:Authservice) {
  
    this._authService.tokenEvent.subscribe(res =&gt; {  //subscribing to token event in authservice
      if (res) {
        this.storage.get('token')
          .then(token =&gt; {
             this.authtoken = token
          });
        }
      })
    }
  
    get(url){
           let headers = new Headers();
        this.createGeneralHeaders(headers);
         return Observable
             .flatMap(   //retuns an error flatmap doesnt exist on observable
             name =&gt; this.http.get(`${url}?access-token=${this.authtoken}`, {headers})
         );
  
       }
  </code></pre>
  
  <p>In the authservice where am setting the token</p>
  
  <pre><code> tokenEvent: Subject&lt;any&gt; = new BehaviorSubject(null);
  
    login(user: UserModel): Observable&lt;any&gt; {
      return this._http.post(this.loginurl + "mobile-login", body)
       .map((response: Response) =&gt; {
          let token = response.json().access_token;
         if (token) {
            this.storage.set('token', token).then(res =&gt; this.tokenEvent.next(true));
        return true;
      }
    })
  //.catch(this.handleError);
  </code></pre>
  
  <p>}</p>
  
  <p>Now i can easily use the get from the first service in any http request like</p>
  
  <pre><code>getChecklists(truckid): Observable&lt;any&gt; {
  
  return this._httpclient.get(this.inspectionurl + "get-checklists")
    .map(res=&gt;res.json().data)
  </code></pre>
  
  <p>}</p>
  
  <p>The above first service retuns an error that flatmap doesnt exist. How do i adjust the first service to be used in another http request and also attach a token from the token event</p>
  
  <p>The two solutions are based on the <a href="https://stackoverflow.com/questions/42183223/custom-http-request-returns-an-error-in-angular2/42183701?noredirect=1#comment71535639_42183701">this question</a> and <a href="https://stackoverflow.com/questions/42185464/ionic2-set-and-retrieve-the-value-of-storage-fails">this question</a></p>