I am working on an app that uses an API from a different domain that I have no control over it's header.
The API allows to post to it's api by passing it a username and a key in the url. The method needs to be post and the code would like something like this.
$http({
url : url,
method : "POST",
headers : {
'Content-Type' : 'application/json'
},
data : {
name: "joe", number: 1234567890
}
}).success(function(data) {
//do something
});
the data being posted is being pass as an object like above.
I'm new to CORS but I have a conceptual idea. Again I have to access to the API. The instructions say that I need to send a post request and pass in a header of the content type 'Content-Type' : 'application/json'
Any help is welcomed, I have looked at post that change angular's settings in the config method
$httpProvider.defaults.withCredentials = true;
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
But it doesn't do anything. I believe this was a fix to an older version of Angular. Other solutions require access to the server which I don't have. The header response looks something like this
Allow GET,PUT,POST,PATCH,HEAD,OPTIONS
Content-Encoding gzip
Content-Type text/html; charset=utf-8
Date Wed, 15 Oct 2014 06:42:43 GMT
P3P policyref="https://www.somedomaincom/w3c/p3p.xml", CP="NON DSP COR CURa ADMa DEVa PSAa PSDa IVAa IVDa CONa TELa OUR STP PHY ONL COM NAV INT DEM CNT PRE"
Server nginx/1.1.19
Transfer-Encoding chunked
Vary Host, Cookie