2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-23 20:40:40 +03:00

Updating README

This commit is contained in:
mzabriskie
2014-10-15 12:10:26 -06:00
parent 5fce14d9ec
commit 7e422d1463
+20 -2
View File
@@ -10,7 +10,6 @@ Promise based HTTP client for the browser and node.js
- Transform request and response data - Transform request and response data
- Automatic transforms for JSON data - Automatic transforms for JSON data
- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) - Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery)
- Specify HTTP request headers
## Installing ## Installing
@@ -81,7 +80,7 @@ function getUserAccount() {
} }
function getUserPermissions() { function getUserPermissions() {
return axios.get('/user/permissions/12345'); return axios.get('/user/12345/permissions');
} }
axios.all([getUserAccount(), getUserPermissions()]) axios.all([getUserAccount(), getUserPermissions()])
@@ -216,6 +215,25 @@ axios.get('/user/12345')
}); });
``` ```
## Handling Errors
```js
axios.get('/user/12345')
.catch(function (response) {
if (response instanceof Error) {
// Something happened in setting up the request that triggered an Error
console.log('Error', response.message);
} else {
// The request was made, but the server responded with a status code
// that falls out of the range of 2xx
console.log(response.data);
console.log(response.status);
console.log(response.headers);
console.log(response.config);
}
});
```
## Credits ## Credits
axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular. axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular.