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

Commit 1fe0d99

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 f2f5a1d commit 1fe0d99

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
@@ -328,14 +328,14 @@ function $HttpProvider() {
328328
*
329329
* There are two kinds of interceptors (and two kinds of rejection interceptors):
330330
*
331-
* * `request`: interceptors get called with http `config` object. The function is free to
332-
* modify the `config` or create a new one. The function needs to return the `config`
333-
* directly or as a promise.
331+
* * `request`: interceptors get called with a http `config` object. The function is free to
332+
* modify the `config` object or create a new one. The function needs to return the `config`
333+
* object directly, or a promise containing the `config` or a new `config` object.
334334
* * `requestError`: interceptor gets called when a previous interceptor threw an error or
335335
* resolved with a rejection.
336336
* * `response`: interceptors get called with http `response` object. The function is free to
337-
* modify the `response` or create a new one. The function needs to return the `response`
338-
* directly or as a promise.
337+
* modify the `response` object or create a new one. The function needs to return the `response`
338+
* object directly, or as a promise containing the `response` or a new `response` object.
339339
* * `responseError`: interceptor gets called when a previous interceptor threw an error or
340340
* resolved with a rejection.
341341
*
@@ -347,7 +347,7 @@ function $HttpProvider() {
347347
* // optional method
348348
* 'request': function(config) {
349349
* // do something on success
350-
* return config || $q.when(config);
350+
* return config;
351351
* },
352352
*
353353
* // optional method
@@ -364,7 +364,7 @@ function $HttpProvider() {
364364
* // optional method
365365
* 'response': function(response) {
366366
* // do something on success
367-
* return response || $q.when(response);
367+
* return response;
368368
* },
369369
*
370370
* // optional method

0 commit comments

Comments
 (0)