Two important points at the beginning:
1) I have no access to server side, so I can't configure CORS normally.
2) I can see the response with correct data in Network tab at Chrome Dev Console.
The problem: I receive a very common error: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://someorigin' is therefore not allowed access.
So my code goes to error section and the data
is null:
getItems: function (count, offset, properties) {
var deferred = $q.defer();
var urlBase = 'items/list/';
var timestamp = getTimestamp();
var params = {count: count, offset: offset, includedProperties: properties, returnProperties: "true"};
var query = getQuery(urlBase, params, timestamp);
$http({
method: 'GET',
url: apiLink + query
}).
success(function (data, status, headers, config) {debugger;
deferred.resolve(data);
}).
error(function (data, status, headers, config) {debugger;
deferred.reject(status);
});
return deferred.promise;
}
But I can see the response data in the Network tab.
Is there a way to resolve $http result with received data?
I have to add, that I can't use params
object inside $http
, because I have to create a HMAC signature on url-query, so the order of query params is important, but using params
object places params in url in unpredictable order.