0

I want to get Location header value(302 HTTP redirect) within an API call success callback. I have tried headers('Location') but console.log() shows null. how can I fetch response headers properly?

Response Headers :

Cache-Control:no-cache
Connection:Keep-Alive
Content-Length:324
Content-Type:text/html; charset=UTF-8
Date:Thu, 15 Oct 2015 18:51:04 GMT
Keep-Alive:timeout=5, max=100
Location:http://localhost/redirect --------------- Redirect Uri
Server:Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.12

Angular success callback :

.success(function (data, status, headers, config) {
    window.location.href = headers('Location');
})
3
  • @KateMihalikova this is not my Q Commented Oct 15, 2015 at 20:16
  • 1
    As XMLHttpRequest (used by angular) transparently follows redirects, there is no way to get a Location header from first (= different) response headers, as you can read there. Commented Oct 15, 2015 at 20:29
  • @KateMihalikova thanx, after some research I concluded that you are right lady :) Commented Oct 15, 2015 at 21:44

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.