im need to replicate this Jquery ajax functionality:
$.ajax({
type: 'POST',
url: 'https://api.url.gift/api',
data: JSON.stringify({ "user_id": "100006" }),
success: function(result) {
console.log("asd");
console.log(result);
},
error: function(xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
},
});
Which works fine, but when I do this in AngularJS:
var myData = JSON.stringify({"user_id": "100006" });
$http({
url: 'https://api.ecosquared.gift/things/cards/received_byme',
method: 'POST',
data: myData,
headers: { 'Content-Type': 'application/json; charset=UTF-8'},
}).success(function(data, status, headers, config){
console.log(data);
}).error(function(data, status, headers, config) {
console.log(data);
});
I get:
XMLHttpRequest cannot load https://api.url.gift/api. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://url.gift' is therefore not allowed access. The response had HTTP status code 405.
One weird thing, if I dont send data parameter, the request goes trough and that error dont raises, but of course the API dont return the data I expect.
Can someone point me in the right direction?