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

Commit 25ae98c

Browse files
fwielstraIgorMinar
authored andcommitted
docs($http): clear up Interceptor docs and code
The documentation and code example of $http interceptors is unclear about whether config can be null or not, and whether the result should always be a promise or not. This pr clears up the documentation a bit and removes the literal 'or a promise' interpretation of the docs in the code example. Closes #7431 Closes #7460
1 parent adb5ee2 commit 25ae98c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/ng/http.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,14 @@ function $HttpProvider() {
355355
*
356356
* There are two kinds of interceptors (and two kinds of rejection interceptors):
357357
*
358-
* * `request`: interceptors get called with http `config` object. The function is free to
359-
* modify the `config` or create a new one. The function needs to return the `config`
360-
* directly or as a promise.
358+
* * `request`: interceptors get called with a http `config` object. The function is free to
359+
* modify the `config` object or create a new one. The function needs to return the `config`
360+
* object directly, or a promise containing the `config` or a new `config` object.
361361
* * `requestError`: interceptor gets called when a previous interceptor threw an error or
362362
* resolved with a rejection.
363363
* * `response`: interceptors get called with http `response` object. The function is free to
364-
* modify the `response` or create a new one. The function needs to return the `response`
365-
* directly or as a promise.
364+
* modify the `response` object or create a new one. The function needs to return the `response`
365+
* object directly, or as a promise containing the `response` or a new `response` object.
366366
* * `responseError`: interceptor gets called when a previous interceptor threw an error or
367367
* resolved with a rejection.
368368
*
@@ -374,7 +374,7 @@ function $HttpProvider() {
374374
* // optional method
375375
* 'request': function(config) {
376376
* // do something on success
377-
* return config || $q.when(config);
377+
* return config;
378378
* },
379379
*
380380
* // optional method
@@ -391,7 +391,7 @@ function $HttpProvider() {
391391
* // optional method
392392
* 'response': function(response) {
393393
* // do something on success
394-
* return response || $q.when(response);
394+
* return response;
395395
* },
396396
*
397397
* // optional method

0 commit comments

Comments
 (0)