星期一, 6月 16, 2014

[AngularJS] $http無法送出 content-type header

踩了一個簡單的雷$http,記錄一下XD
發現$http呼叫API時,無法加入content-type的header。
   $http({
     url: apiEndpoint,
     method: 'GET',
     data: '',
     headers: {
      'Content-Type': 'applicstio/json'
     }
    }).success(function(data, status, headers, config) {

     

    }).error(function(data, status, headers, config){
     
    });


You need to include a body with the request. Angular removes the content-type header otherwise.
Add data: '' to the argument to $http.

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails