How to read response headers in angularjs?

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

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

\"enter

7条回答
  •  自闭症患者
    2020-11-27 17:40

    Additionally to Eugene Retunsky's answer, quoting from $http documentation regarding the response:

    The response object has these properties:

    • 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.

    Please note that the argument callback order for $resource (v1.6) is not the same as above:

    Success callback is called with (value (Object|Array), responseHeaders (Function), status (number), statusText (string)) arguments, where the value is the populated resource instance or collection object. The error callback is called with (httpResponse) argument.

提交回复
热议问题