http DELETE错误400 - 试图找到原因

时间:2015-07-15 19:03:17

标签: javascript angularjs

对于带有POST请求的“followUser”,我有完全相同的代码并且它可以工作..出于某种奇怪的原因删除错误400

服务:

this.unFollow = function (to_from, token) {
            $http.defaults.headers.common['auth_token'] =  token;
            return $http.delete($rootScope.endPoint + '/user/follow/', to_from);    
        };

控制器:

$scope.unFollowUser =function(userid, index){

   var to_from =  {to_user: userid, from_user: $localStorage.CurrentUser.id};
console.log(to_from);
  UserService.unFollow(to_from, $localStorage.CurrentUser.auth_token)
        .success(function (data) {
          $scope.users[index].is_following = false;

          }).
        error(function(error, status) {         
          //alert(status);
          console.log(error);         
      });

}

1 个答案:

答案 0 :(得分:0)

当您呼叫$http.delete(url, options)时,您没有使用有效的选项对象。也许试试这样称呼:

$http.delete($rootScope.endpoint + '/user/follow', { data: to_from } );

https://docs.angularjs.org/api/ng/service/ $ HTTP

相关问题