title: Periodically calling an health check API in Angular
body: <p>I am new in angular and trying to build a health check connection to check the availability of my backend im background. This check will run periodically each 5s to check if an 200 OK status is received:</p>
  <p>Here is my service:</p>
  <pre><code>healthCheck() {
      return this.http.get&lt;any&gt;(this.healthCheckAPI, { observe: 'response' })
        .pipe(
          map((resp: any) =&gt; {
            if(resp.status !== 200){
              throw resp;
            }
            return resp.status;
          }),
          repeatWhen(() =&gt; interval(5000)),
          retryWhen(errors =&gt; errors.pipe(delay(5000)))
        );
    }
  </code></pre>
  <p>And here is inside of my component:</p>
  <pre><code>this.apiService.healthCheck().subscribe(
        (data) =&gt; {
          //perform some stuff when 200 is returned
        },
        (error) =&gt; {
          //perform some stuff when error is returned
        }
      );
  </code></pre>
  <p>In the <code>subscribe()</code> method in my component, I successfully got the status 200 when the healthCheck is successful, but why I never get the error part in my subscribe method, even when the backend is unavailable? I thought in that case, the service will call the <code>retryWhen()</code> in the background and return the error to the component so that I can make some operation there, or did I miss something?</p>