How to read response headers in angularjs?

前端 未结 7 1360
终归单人心
终归单人心 2020-11-27 17:17

My server returns this kind of header: Content-Range:0-10/0:

\"enter

7条回答
  •  再見小時候
    2020-11-27 17:30

    Why not simply try this:

    var promise = $http.get(url, {
        params: query
    }).then(function(response) {
      console.log('Content-Range: ' + response.headers('Content-Range'));
      return response.data;
    });
    

    Especially if you want to return the promise so it could be a part of a promises chain.

提交回复
热议问题