これはあなたが探している答えではないかもしれませんが、私の考えを共有します。angular $http を使用しています。私が行う方法は、すべての API 呼び出しで正しいヘッダーを指定することです。
このようなもの:
authenticatePlayer: function(postData) {
return $http({
method : 'POST',
url : api + 'auth/player',
data : postData,
headers : {'Content-Type' : 'application/json'}
});
},
uploadAvatar: function(email_address, fd) {
return $http({
method : 'POST',
url : api + 'player/' + email_address + '/avatar',
data : fd,
withCredentials: true,
headers : {'Content-Type' : undefined, 'X-Token' : credential.token},
transformRequest: angular.identity //awesome! automatically set to the correct header request
});
},
fbLogin: function(data) {
var xsrf = $.param({fb_access_token: data});
// console.log(postData);
return $http({
method : 'POST',
url : api + '/user/v1/login',
data : xsrf,
headers : {'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'}
});
}
私は角度の専門家ではありませんが、これが私のやり方です。それが役に立てば幸い :)