Angular 1.x Unable to get response header from a get .

9 views
Skip to first unread message

Albert LeVert

unread,
Feb 25, 2019, 12:14:37 PM2/25/19
to Angular and AngularJS discussion
Hello, i try to fetch a xcrsf Token  and it's working great when i disable the cors in localhost.

var deferred = $q.defer();
$http({
url: reservationsEndPoint,
method: 'GET',
withCredentials: true,
headers:
{'X-CSRF-Token':'Fetch'},
timeout:5000,
}).then(function (response) {
// console.log(response.headers('x-csrf-token'));
// var xcsrfToken = response.headers('x-csrf-token');
// xcsrfToken = response.headers('x-csrf-token');
deferred.resolve(response);
}, function (error) {
deferred.reject(error.data.error.message.value);
});
return deferred.promise;


But when i try with cors enabled, preflight call options are made automaically by browser :

And when i try to fetch the token from the response, i get nothing because of the options!

Thank you for your help 


Reply all
Reply to author
Forward
0 new messages