mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
Updating README
This commit is contained in:
@@ -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()])
|
||||||
@@ -213,6 +212,25 @@ axios.get('/user/12345')
|
|||||||
console.log(response.status);
|
console.log(response.status);
|
||||||
console.log(response.headers);
|
console.log(response.headers);
|
||||||
console.log(response.config);
|
console.log(response.config);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user