title: http wait for another call finish
body: <p><strong>scenario</strong>:</p>
  <ul>
  <li>members and non-members have different contents in the same page, e.g. news, user info</li>
  <li>&quot;remember me&quot; feature is available</li>
  <li>check the token in local storage with server to verify user when website is loaded</li>
  <li>most of http request result will be different based on login status</li>
  </ul>
  <p><strong>problem</strong>:</p>
  <ul>
  <li>how can I wait for user validation before all http request is triggered?</li>
  </ul>
  <p><strong>http.service.ts sample code</strong>:</p>
  <pre><code>  private isReady = false;
  
    constructor(private httpClient: HttpClient) {
      this.init();
    }
  
    // pass local data to check user login status
    // check the token, expired date etc.
    public init() {
      // this.httpClient.post to verify user status
      // this.isReady = true;
    }
  
    // http get request used in other components
    public get(url) {
      if (this.isReady) {
        return this.httpClient.get&lt;any&gt;(this.apiRoot + url);
      } else {
        // how to wait for init() is done before return in here?
        return this.httpClient.get&lt;any&gt;(this.apiRoot + url);
      }
    }
  </code></pre>
  <p>sandbox sample is <a href="https://codesandbox.io/s/unruffled-firefly-z5t4h?file=/src/app/http.service.ts" rel="nofollow noreferrer">here</a></p>