Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 85286bd

Browse files
committed
docs($http): move response object documentation into Usage section
1 parent 1faf7ec commit 85286bd

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
@@ -434,7 +434,9 @@ function $HttpProvider() {
434434
*
435435
* ## General usage
436436
* The `$http` service is a function which takes a single argument — a {@link $http#usage configuration object} —
437-
* that is used to generate an HTTP request and returns a {@link ng.$q promise}.
437+
* that is used to generate an HTTP request and returns a {@link ng.$q promise} that is
438+
* resolved (request success) or rejected (request failure) with a
439+
* {@link ng.$http#$http-returns response} object.
438440
*
439441
* ```js
440442
* // Simple GET request example:
@@ -450,24 +452,6 @@ function $HttpProvider() {
450452
* });
451453
* ```
452454
*
453-
* The response object has these properties:
454-
*
455-
* - **data** – `{string|Object}` – The response body transformed with the transform
456-
* functions.
457-
* - **status** – `{number}` – HTTP status code of the response.
458-
* - **headers** – `{function([headerName])}` – Header getter function.
459-
* - **config** – `{Object}` – The configuration object that was used to generate the request.
460-
* - **statusText** – `{string}` – HTTP status text of the response.
461-
* - **xhrStatus** – `{string}` – Status of the XMLHttpRequest (`complete`, `error`, `timeout` or `abort`).
462-
*
463-
* A response status code between 200 and 299 is considered a success status and will result in
464-
* the success callback being called. Any response status code outside of that range is
465-
* considered an error status and will result in the error callback being called.
466-
* Also, status codes less than -1 are normalized to zero. -1 usually means the request was
467-
* aborted, e.g. using a `config.timeout`.
468-
* Note that if the response is a redirect, XMLHttpRequest will transparently follow it, meaning
469-
* that the outcome (success or error) will be determined by the final response status code.
470-
*
471455
*
472456
* ## Shortcut methods
473457
*
@@ -853,8 +837,33 @@ function $HttpProvider() {
853837
* - **responseType** - `{string}` - see
854838
* [XMLHttpRequest.responseType](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#xmlhttprequest-responsetype).
855839
*
856-
* @returns {HttpPromise} Returns a {@link ng.$q `Promise}` that will be resolved to a response object
857-
* when the request succeeds or fails.
840+
* @returns {HttpPromise} A {@link ng.$q `Promise}` that will be resolved (request success)
841+
* or rejected (request failure) with a response object.
842+
*
843+
* The response object has these properties:
844+
*
845+
* - **data** – `{string|Object}` – The response body transformed with
846+
* the transform functions.
847+
* - **status** – `{number}` – HTTP status code of the response.
848+
* - **headers** – `{function([headerName])}` – Header getter function.
849+
* - **config** – `{Object}` – The configuration object that was used
850+
* to generate the request.
851+
* - **statusText** – `{string}` – HTTP status text of the response.
852+
* - **xhrStatus** – `{string}` – Status of the XMLHttpRequest
853+
* (`complete`, `error`, `timeout` or `abort`).
854+
*
855+
*
856+
* A response status code between 200 and 299 is considered a success status
857+
* and will result in the success callback being called. Any response status
858+
* code outside of that range is considered an error status and will result
859+
* in the error callback being called.
860+
* Also, status codes less than -1 are normalized to zero. -1 usually means
861+
* the request was aborted, e.g. using a `config.timeout`. More information
862+
* about the status might be available in the `xhrStatus` property.
863+
*
864+
* Note that if the response is a redirect, XMLHttpRequest will transparently
865+
* follow it, meaning that the outcome (success or error) will be determined
866+
* by the final response status code.
858867
*
859868
*
860869
* @property {Array.<Object>} pendingRequests Array of config objects for currently pending
@@ -1104,8 +1113,9 @@ function $HttpProvider() {
11041113
*
11051114
* @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
11061115
* or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1107-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1108-
* @returns {HttpPromise} Future object
1116+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1117+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1118+
* See {@link ng.$http#$http-returns `$http()` return value}.
11091119
*/
11101120

11111121
/**
@@ -1117,8 +1127,9 @@ function $HttpProvider() {
11171127
*
11181128
* @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
11191129
* or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1120-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1121-
* @returns {HttpPromise} Future object
1130+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1131+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1132+
* See {@link ng.$http#$http-returns `$http()` return value}.
11221133
*/
11231134

11241135
/**
@@ -1130,8 +1141,9 @@ function $HttpProvider() {
11301141
*
11311142
* @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
11321143
* or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1133-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1134-
* @returns {HttpPromise} Future object
1144+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1145+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1146+
* See {@link ng.$http#$http-returns `$http()` return value}.
11351147
*/
11361148

11371149
/**
@@ -1172,8 +1184,9 @@ function $HttpProvider() {
11721184
*
11731185
* @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
11741186
* or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1175-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1176-
* @returns {HttpPromise} Future object
1187+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1188+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1189+
* See {@link ng.$http#$http-returns `$http()` return value}.
11771190
*/
11781191
createShortMethods('get', 'delete', 'head', 'jsonp');
11791192

@@ -1186,8 +1199,9 @@ function $HttpProvider() {
11861199
*
11871200
* @param {string} url Relative or absolute URL specifying the destination of the request
11881201
* @param {*} data Request content
1189-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1190-
* @returns {HttpPromise} Future object
1202+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1203+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1204+
* See {@link ng.$http#$http-returns `$http()` return value}.
11911205
*/
11921206

11931207
/**
@@ -1199,8 +1213,9 @@ function $HttpProvider() {
11991213
*
12001214
* @param {string} url Relative or absolute URL specifying the destination of the request
12011215
* @param {*} data Request content
1202-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1203-
* @returns {HttpPromise} Future object
1216+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1217+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1218+
* See {@link ng.$http#$http-returns `$http()` return value}.
12041219
*/
12051220

12061221
/**
@@ -1212,8 +1227,9 @@ function $HttpProvider() {
12121227
*
12131228
* @param {string} url Relative or absolute URL specifying the destination of the request
12141229
* @param {*} data Request content
1215-
* @param {Object=} config Optional configuration object. See https://docs.angularjs.org/api/ng/service/$http#usage
1216-
* @returns {HttpPromise} Future object
1230+
* @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1231+
* @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
1232+
* See {@link ng.$http#$http-returns `$http()` return value}.
12171233
*/
12181234
createShortMethodsWithData('post', 'put', 'patch');
12191235

0 commit comments

Comments
 (0)