2016-04-10 8 views
1

私はREST API(Spring Bootを使用して開発)を持っていますが、フロントエンドでAngularJS 1.5を使用しています。そして$http docsからangularjs側ヘッダAngularJS:HttpResponseからデータとヘッダーの両方を読み取る

var LocalBusinessUserResource = $resource(apiService + '/localbusinessusers/login'); 
var deferred = $q.defer(); 
      LocalBusinessUserResource.get(credantials, function (result) { 
       console.log('result: ' + JSON.stringify(result)); 
       deferred.resolve(result); 
      }, function() { 
       console.error('check your server connection'); 
      }); 
      return deferred.promise; 

答えて

0

応答オブジェクトは、これらの特性を有する:

data – {string|Object} – The response body transformed with the transform functions. 
status – {number} – HTTP status code of the response. 
headers – {function([headerName])} – Header getter function. 
config – {Object} – The configuration object that was used to generate the request. 
statusText – {string} – HTTP status text of the response. 

応答データを取得した同じオブジェクトの応答ヘッダーにアクセスできます。

+0

私は$ httpを使用していません。すべての呼び出しで私は$ resourceを使用しました。 – jemlifathi

+0

ああ、私の間違いです。その場合、コールバックに2番目のパラメータを追加することで、レスポンスヘッダにアクセスできるはずです。 'LocalBusinessUserResource.get(credantials、function(result、responseHeaders){...'; – unscsprt

+0

私はこれを前に試しました。定義されていない – jemlifathi

関連する問題