title: angular - how to handle redirect
body: <p>I use spring security, which redirects unauthenticated users to a login page.</p>
  
  <p>So when an unauthenticated angular client sends a GET request to an endpoint (expecting JSON), it receives the HTML content of the login page, and the JSON parser fails (<a href="https://stackoverflow.com/questions/36885556/angular2-watch-for-302-redirect-when-fetching-resource">Angular2 watch for 302 redirect when fetching resource</a>)</p>
  
  <pre><code>const httpObservable = this.http.get(urlThatWillRedirect).subscribe(data =&gt; ...) // JSON parser will fail
  </code></pre>
  
  <p>How can I handle redirects in Angular?</p>