金字塔不适用于角$ http帖子

lut*_*hur 5 pyramid angularjs cornice

$http({method: 'POST', url: 'http://localhost:5001/products', data: {token: $scope.product.token}}).success(
    function () {
        alert('success');
    }
);
Run Code Online (Sandbox Code Playgroud)

在金字塔方面,request.POST显示NOVars:不是表单请求.不是HTML表单提交(Content-Type:application/json)

我使用檐口提供我的api(/产品),我认为这是金字塔的问题.

有没有人有办法解决吗?

Tal*_*ner 0

尝试在 $http 中设置 contenttype,如下所示。

 $http(
           {
               url: url,
               contentType: "application/json",
               data: data,
               method: method
           })
           .success(function (response) {
               successcb(response);
           }).error(function (data, status, headers, config) { errorcb(data); });
  };
Run Code Online (Sandbox Code Playgroud)