javascript - Angular2 , How to prevent from HTTP redirection -


i trying simulating user login angular2 http. let describe situation bellow.
have php application users can login throw http://sample.com/login.php url (a form exist username , password input, user should fill inputs , press submit button) , if login success, redirect http://sample.com/dashboard.php.
create http post form data has "username" , "password" within. , set http header content-type application/x-www-form-urlencoded.
login works fine , request automatically redirect http://sample.com/dashboard.php .
problem need access first request response header(http://sample.com/login.php), http response me second request response header (http://sample.com/dashboard.php).
way prevent http redirecting? or throw error on status 302 ?

var headers = new headers({'content-type':'application/x-www-form-urlencoded'}); var options = new requestoptions({ headers: headers }); http.post("http://sample.com/login.php",'username=admin&password=123' , options)     .subscribe(success => {         // success , return redirected response         // response of http://sample.com/dashboard.php     }, error => {         // error handler     } ); 

this not possible because xmlhttprequest (low level api) not expose such method.

for more details @ this:

prevent redirection of xmlhttprequest