0

すべての呼び出しにカスタム ヘッダーを追加することなく、AngularJS アプリにカスタム ヘッダーを追加する方法はあるのでしょうか。

これまでのところ、私の呼び出しの例は次のようになります。

$http.get('http://api.discogs.com/artists/' + $scope.artist.id + '/releases?page=' +       $scope.nextPage + '&per_page=8').then(function(data2) {
    $scope.nextPage = $scope.nextPage + 1;
    if($scope.nextPage > data2.data.pagination.pages){
       $scope.morePages = false;
    }
    $scope.releases = $scope.releases.concat(data2.data.releases);
})
.finally(function(){
    $scope.loading = false;
}); 

別の質問で、誰かが次のようなヘッダーを含めることを確認しました。

$http({method: 'GET', url: 'http://localhost:3000/api/symbol/junk', 
       headers:{
         'Access-Control-Allow-Origin': '*',
         'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
         'Access-Control-Allow-Headers': 'Content-Type, X-Requested-With',
         'X-Random-Shit':'123123123'
       }})
      .success(function(d){ console.log( "yay" ); })

しかし、最初に、それを自分の通話に統合する方法がわかりません。次に、これはすべての通話ではなく、1 つの通話でのみ機能すると思います。

任意のヒント?

ありがとう!

4

1 に答える 1