AngularJs Header manipulation

XMLHttpRequest cannot load {/api/call}. Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.

TypeError: Cannot convert object to primitive value

if you are using Angular.js 1.4.0 or later, use header : to manipulate rather than transformRequest:

var req = {
method: ‘GET’,
url: ‘api/call’.format(password, username),
headers: {
‘Authorization’: undefined
}
};

$http(req)
.
.success(function(response) {
console.log(response);
callback(response);
})
.error(function(err) {
console.log(err);
callback(response);
});

Advertisements

Blog at WordPress.com.

Up ↑

%d bloggers like this: