0

I've tried to access response headers through $http provider without success. In my research I read that it's a CORS issue. But that doesn't make any sense because reading the headers in GoogleChrome inspector(Network section), the headers are there. Code:

$http({
   method: 'POST',
   "url" : url,
   "headers":{
      "Content-Type":"application/json",
      "Ocp-Apim-Subscription-Key":"<SECRETKEY>"
    },
    "data": {"video":fileData}
}).then(
  function successCallback(res){
    console.log("SUCCESS!");
    console.log("RESPONSE JSON ON SERVICE: " + JSON.stringify( res ) );
    console.log("HTTP HEADERS" + JSON.stringify($http.headers) );
    sucxCallback(res.headers);//this came undefined... 
  }
  ,function errorCallback(res){
    console.log("FAIL!")
  }
 );

There is something I can do? I'm considering to change $http to $ajax. Alternatives?

Thx!

AT82
  • 71,416
  • 24
  • 140
  • 167
Andre Carneiro
  • 708
  • 1
  • 5
  • 27
  • Which AngularJs version do you use? Can you try `res.headers('X-MyHeader')` – ChrisY Jun 22 '17 at 20:40
  • Angular 1.6.4 - and rs.headers('X-Operation-Location') returns null... – Andre Carneiro Jun 22 '17 at 20:52
  • Hi! Sorry for the late response. According to this question https://stackoverflow.com/questions/32404092/response-header-is-present-in-browser-but-not-parsed-by-angular-http-response-h it still could be a CORS issue. – ChrisY Jun 24 '17 at 17:57
  • I solved replacing '$http' with the '$ajax'. Unfortunatelly I have no access to Cognitive Server to be able to add headers that satisfy CORS. But, thanks anyway! – Andre Carneiro Jun 26 '17 at 13:24
  • Possible duplicate of [Response header is present in browser but not parsed by Angular $http response.headers()](https://stackoverflow.com/questions/32404092/response-header-is-present-in-browser-but-not-parsed-by-angular-http-response-h) – Sajith May 01 '18 at 07:07

0 Answers0