문제

Quite simply! Why does this NOT work:

      $http.post(apiUrl + '/some/url/blah', {params: data, withCredentials: true})
      .then(function(result){
          //success!
      });

Yet this DOES!!

      $http({
          method: 'POST',
          withCredentials: true,
          url: apiUrl + '/some/url/blah',
          params: data
      })
      .success(function(data, status, headers, config) {
          //success!!
      });

I get a 401 unauthorized on the 1st example! second works like a charm..

도움이 되었습니까?

해결책

When using the $http.post shorthand, the second parameter is the data. Try this:

$http.post(apiUrl + '/some/url/blah', {}, {params: data, withCredentials: true})
  .then(function(result){
      //success!
  });
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top