Angular 2, catching 401 in @ngrx/effects
<p>I've got @ngrx/store and effects working fine, however, I just realized there will be a a lot of API calls (in effects), and if any of those returns a 401 error I should redirect the user to the login page. My problem is: I don't want to check that in every single effect, that would be a ton extra code for the same thing. Let's say for example I have a code like this:</p>

<p><strong>Sample effect</strong></p>

<pre><code>@Effect() getMe$ = this.actions$
    .ofType(GET_ME)
    .map(action =&gt; action.payload)
    .switchMap(payload =&gt; this.userService.me()
        .map(res =&gt; ({ type: GET_ME_SUCCESS, payload: res }))
        .catch(() =&gt; Observable.of({ type: GET_ME_FAILURE }))
    );
</code></pre>

<p><strong>userService.me()</strong></p>

<pre><code>me(): Observable&lt;User&gt; {
  return this.apiService.get(`/auth/me`);
}
</code></pre>

<p><strong>apiService.get()</strong></p>

<pre><code>get(endpoint: string): Observable&lt;any&gt; {
  return this.http.get(`${this.base}${endpoint}`, this.options())
    .map(res =&gt; res.json());
}
</code></pre>

<p>This works perfectly fine, but I'm not sure how to handle the case when the API return <strong>401</strong>. Where should I redirect the user globally in that case? Should I create an action for that case? Where should I dispatch that action then? Or am I doing it completely wrong?</p>

<p>Any help in the right direction would be appreciated!</p>