0

I use swagger to call api it works (for 'GET', 'POST' and 'PUT'), but when I was trying to call API via $resource method: 'PUT', it gives me OPTIONS, and cannot make the call. Is there someone who knows how to fix this? Below attached code:

var data = $resource('url', {id: '@id'}, { update: { method: 'PUT'}});
var modifyObject = function (obj) {
    var deferred = $q.defer();
    data.update({id: obj.id}, obj, function (data) {
        deferred.resolve(data);
    }, function (error) {
        deferred.reject(error);
    });
    return deferred.promise;
};
modifyObject(requestObj).then(function (data) {
        console.log(data);
    },
    function (error) {
        console.log(error);
    }
);

Attached the resolve and same issue: How does Access-Control-Allow-Origin header work?

Community
  • 1
  • 1
KATHERINE
  • 109
  • 1
  • 8
  • This is usually a server-side issue. Specifying the header `Access-Control-Allow-Origin: 'yoursite.com'` or `'*'` should do – Taku Nov 17 '16 at 04:10
  • Please refer following link to solve issue - http://stackoverflow.com/questions/10636611/how-does-access-control-allow-origin-header-work – Avinash Rathod Nov 17 '16 at 05:08
  • Thanks, you are right, it has been fixed on the Server-side in API. Thanks – KATHERINE Jan 11 '17 at 21:02

0 Answers0