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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: