我使用招摇来调用api它有效(对于' GET',' POST'' PUT'), 但当我试图通过$ resource方法调用API时:' PUT', 它给了我OPTIONS,并且无法拨打电话。有人知道如何解决这个问题吗?下面附上代码:
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);
}
);
附上决心和同样的问题: How does Access-Control-Allow-Origin header work?