나는 angularjs를 처음 사용합니다. 승인이 필요한 API 요청을하려고합니다. 요청의 헤더에 포함 시켰지만 여전히 작동하지 않습니다. 내 액세스 토큰이 작동하고 있다고 확신합니다. 어떤 충고?AngularJS 요청에 헤더를 포함하는 방법
$scope.fetch = function() {
$scope.code = null;
$scope.response = null;
$http({
method: $scope.method,
url: $scope.url,
cache: $templateCache,
headers: {
Authorization: "access token"
}
}).
success(function(data, status) {
$scope.status = status;
$scope.data = data;
}).
error(function(data, status) {
$scope.data = data || "Request failed";
$scope.status = status;
});
};
액세스 토큰 앞에 "기본"을 추가하십시오. 여기에이 중 하나가 중복 될 수 있습니다. http://stackoverflow.com/questions/11876777/angularjs-set-http-header-for-one-request –