Skip to content

Commit 64c23e4

Browse files
committed
docs($http): move response object documentation into Usage section
1 parent 7e2e235 commit 64c23e4

File tree

1 file changed

+51
-35
lines changed

1 file changed

+51
-35
lines changed

src/ng/http.js

+51-35
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,9 @@ function $HttpProvider() {
437437
*
438438
* ## General usage
439439
* The `$http` service is a function which takes a single argument — a {@link $http#usage configuration object} —
440-
* that is used to generate an HTTP request and returns a {@link ng.$q promise}.
440+
* that is used to generate an HTTP request and returns a {@link ng.$q promise} that is
441+
* resolved (request success) or rejected (request failure) with a
442+
* {@link ng.$http#$http-returns response} object.
441443
*
442444
* ```js
443445
* // Simple GET request example:
@@ -453,24 +455,6 @@ function $HttpProvider() {
453455
* });
454456
* ```
455457
*
456-
* The response object has these properties:
457-
*
458-
* - **data** – `{string|Object}` – The response body transformed with the transform
459-
* functions.
460-
* - **status** – `{number}` – HTTP status code of the response.
461-
* - **headers** – `{function([headerName])}` – Header getter function.
462-
* - **config** – `{Object}` – The configuration object that was used to generate the request.
463-
* - **statusText** – `{string}` – HTTP status text of the response.
464-
* - **xhrStatus** – `{string}` – Status of the XMLHttpRequest (`complete`, `error`, `timeout` or `abort`).
465-
*
466-
* A response status code between 200 and 299 is considered a success status and will result in
467-
* the success callback being called. Any response status code outside of that range is
468-
* considered an error status and will result in the error callback being called.
469-
* Also, status codes less than -1 are normalized to zero. -1 usually means the request was
470-
* aborted, e.g. using a `config.timeout`.
471-
* Note that if the response is a redirect, XMLHttpRequest will transparently follow it, meaning
472-
* that the outcome (success or error) will be determined by the final response status code.
473-
*
474458
*
475459
* ## Shortcut methods
476460
*
@@ -856,8 +840,33 @@ function $HttpProvider() {
856840
* - **responseType** - `{string}` - see
857841
* [XMLHttpRequest.responseType](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#xmlhttprequest-responsetype).
858842
*
859-
* @returns {HttpPromise} Returns a {@link ng.$q `Promise}` that will be resolved to a response object
860-
* when the request succeeds or fails.
843+
* @returns {HttpPromise} A {@link ng.$q `Promise}` that will be resolved (request success)
844+
* or rejected (request failure) with a response object.
845+
*
846+
* The response object has these properties:
847+
*
848+
* - **data** – `{string|Object}` – The response body transformed with
849+
* the transform functions.
850+
* - **status** – `{number}` – HTTP status code of the response.
851+
* - **headers** – `{function([headerName])}` – Header getter function.
852+
* - **config** – `{Object}` – The configuration object that was used
853+
* to generate the request.
854+
* - **statusText** – `{string}` – HTTP status text of the response.
855+
* - **xhrStatus** – `{string}` – Status of the XMLHttpRequest
856+
* (`complete`, `error`, `timeout` or `abort`).
857+
*
858+
*
859+
* A response status code between 200 and 299 is considered a success status
860+
* and will result in the success callback being called. Any response status
861+
* code outside of that range is considered an error status and will result
862+
* in the error callback being called.
863+
* Also, status codes less than -1 are normalized to zero. -1 usually means
864+
* the request was aborted, e.g. using a `config.timeout`. More information
865+
* about the status might be available in the `xhrStatus` property.
866+
*
867+
* Note that if the response is a redirect, XMLHttpRequest will transparently
868+
* follow it, meaning that the outcome (success or error) will be determined
869+
* by the final response status code.
861870
*
862871
*
863872
* @property {Array.<Object>} pendingRequests Array of config objects for currently pending
@@ -1107,8 +1116,9 @@ function $HttpProvider() {
11071116
*
11081117
* @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
11091118
* or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1110-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1111-
* @returns {HttpPromise} Future object
1119+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1120+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1121+
* See {@link ng.$http#$http-returns `$http()` return value}.
11121122
*/
11131123

11141124
/**
@@ -1120,8 +1130,9 @@ function $HttpProvider() {
11201130
*
11211131
* @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
11221132
* or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1123-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1124-
* @returns {HttpPromise} Future object
1133+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1134+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1135+
* See {@link ng.$http#$http-returns `$http()` return value}.
11251136
*/
11261137

11271138
/**
@@ -1133,8 +1144,9 @@ function $HttpProvider() {
11331144
*
11341145
* @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
11351146
* or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1136-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1137-
* @returns {HttpPromise} Future object
1147+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1148+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1149+
* See {@link ng.$http#$http-returns `$http()` return value}.
11381150
*/
11391151

11401152
/**
@@ -1175,8 +1187,9 @@ function $HttpProvider() {
11751187
*
11761188
* @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
11771189
* or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1178-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1179-
* @returns {HttpPromise} Future object
1190+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1191+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1192+
* See {@link ng.$http#$http-returns `$http()` return value}.
11801193
*/
11811194
createShortMethods('get', 'delete', 'head', 'jsonp');
11821195

@@ -1189,8 +1202,9 @@ function $HttpProvider() {
11891202
*
11901203
* @param {string} url Relative or absolute URL specifying the destination of the request
11911204
* @param {*} data Request content
1192-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1193-
* @returns {HttpPromise} Future object
1205+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1206+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1207+
* See {@link ng.$http#$http-returns `$http()` return value}.
11941208
*/
11951209

11961210
/**
@@ -1202,8 +1216,9 @@ function $HttpProvider() {
12021216
*
12031217
* @param {string} url Relative or absolute URL specifying the destination of the request
12041218
* @param {*} data Request content
1205-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1206-
* @returns {HttpPromise} Future object
1219+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1220+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1221+
* See {@link ng.$http#$http-returns `$http()` return value}.
12071222
*/
12081223

12091224
/**
@@ -1215,8 +1230,9 @@ function $HttpProvider() {
12151230
*
12161231
* @param {string} url Relative or absolute URL specifying the destination of the request
12171232
* @param {*} data Request content
1218-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1219-
* @returns {HttpPromise} Future object
1233+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1234+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1235+
* See {@link ng.$http#$http-returns `$http()` return value}.
12201236
*/
12211237
createShortMethodsWithData('post', 'put', 'patch');
12221238

0 commit comments

Comments
 (0)