forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat($httpProvider): add 'useLegacyPromiseExtensions' configuration
The legacy methods, `success` and `error`, have been deprecated. Set this to `false` to cause `$http` to throw an error if these methods are used in the application. For now it defaults to `true`. In a future release we will remove these methods altogether. DEPRECATION NOTICE: The legacy methods 'success' and 'error' on promises returned by $http are now deprecated. Closes angular#12112 Closes angular#10508
- Loading branch information
1 parent
7b8a16b
commit a8f7e9c
Showing
3 changed files
with
155 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
@ngdoc error | ||
@name $http:legacy | ||
@fullName The `success` and `error` methods on the promise returned from `$http` have been disabled. | ||
@description | ||
|
||
This error occurs when the legacy promise extensions (`success` and `error`) | ||
{@link $httpProvider#useLegacyPromiseExtensions legacy `$http` promise extensions} have been disabled. | ||
|
||
To resolve this error, either turn on the legacy extensions by adding | ||
`$httpProvider.useLegacyPromiseExtensions(true);` to your application's configuration; or refactor you | ||
use of `$http` to use `.then()` rather than `.success()` and `.error()`. | ||
|
||
For example if you code looked like this: | ||
|
||
```js | ||
// Simple GET request example : | ||
$http.get('/someUrl'). | ||
success(function(data, status, headers, config) { | ||
// This callback will be called asynchronously | ||
// when the response is available | ||
}). | ||
error(function(data, status, headers, config) { | ||
// called asynchronously if an error occurs | ||
// or server returns response with an error status. | ||
}); | ||
``` | ||
|
||
then you would change it to look like: | ||
|
||
```js | ||
// Simple GET request example : | ||
$http.get('/someUrl'). | ||
then(function(response) { | ||
// (The response object contains the data, status, headers and config properties) | ||
// This callback will be called asynchronously | ||
// when the response is available. | ||
}, function(response) { | ||
// called asynchronously if an error occurs | ||
// or server returns response with an error status. | ||
}); | ||
``` | ||
|
||
For more information, see the | ||
{@link $httpProvider#useLegacyPromiseExtensions `$httpProvider.useLegacyPromiseExtensions`} | ||
documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters