请求方法不支持PATCH

时间:2018-12-10 19:15:08

标签: jquery api

var promises = [];
var arr = ["5c0eb4ae8973074fd8154593","5c0eb4ae8973074fd8154597","5c0eb4ae8973074fd8154596","5c0eb4ae8973074fd8154595","5c0eb4ae8973074fd8154594"];
for(i=1;i<=arr.length;i++)
{
    promises.push(new new Promise(function(resolve, reject) {
    jQuery.ajax({
       headers : {
                     'Accept' : 'application/json',
                     'Content-Type' : 'application/x-www-form-urlencoded',
                      'Authorization' : 'Bearer tioCGK0tdxLU0PCIu8A37eZtwuBLgecpUwAgXP1814xU0pUb24W1EdoQl9cZqp0nzIQWNj_h1KriDtPu6hpAyQq6HzW823vlQbIZSy9plLVGtuXQWtW1CvzWy9VBLCvcPtEWkWdJbEqPvrzakLMJNEBTa9Wtkv-Ghc9l-QSbMeton5Yz4ppDogxcr3ld-c6Dq14RuzT88dMEtXIDh6o4Un1PWSlIm6P2-VcVw5Bb5TRYHMuApw2SYR-DKPxy0GBVx1mC_Dchw-zEqs4bdQnjoiAOhAsQPGW4Aho-DwhFly-RbWvUj5b_KLRu-QUM0LamAh9qLb04iGJsA0UVx1zFvNODZaxRXQWgBNnXXZY8cfhspjE5uCf8W0Ye3hJH9GIo1MJFGFignHt31N7Kutv3Ja_ipQEjKUaIybhAExrJz0Ed4sePBl4dG7rNwWEh9Swqj91jw4EQuFIPy2BgBHGELKnizaYBLYi32Cyv-5BqP22tfKzJQuYe-LXe7iDEVJY3IL5EkSrvjrqAbWmv29G_4yBMLzbAIjOkr_VQiuneaZJlOlzHm-xVSaBH31lgN-5iPG0Djb4BYrQGUDzhS3CyyMHd6bNcHWDELS6jbIDDmoE'
                 },
       url : 'http://localhost:61615/api/public/sites/52/shopping-carts/5c0eb4778973074fd8154506/tickets/'+arr[i]+'/attendees',
                 type : 'PATCH',
                  data : 'firstName=Test'+i+ '&lastName=Test'+i,
          success: function(response, textStatus, jqXhr)
{
 resolve();
         console.log("API Successful!" + textStatus, response);
         },
error: function(jqXHR, textStatus, errorThrown)
{
reject();
             // log the error to the console
             console.log("The following error occured: " + textStatus, errorThrown);
         }
        })}));
    }
Promise.all(promises).then(function() {
// do something...
console.log("ran successfully!66");
});

未捕获(承诺)TypeError:请求方法“ PATCH”不受支持     在newtab-serviceworker.js:61

当我尝试运行此API时,它给了我上面的错误...当我在没有承诺的情况下运行它时,它运行成功但在有承诺的情况下却出现了错误...但是出于某些原因,我想以承诺的方式运行它...

0 个答案:

没有答案