Вопрос

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