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-09-16 12:03:46 -06:00
parent 59eb2b6204
commit 679ec09b39
+36 -15
View File
@@ -196,24 +196,45 @@ This is the available config options for making requests. Only the `url` is requ
## Response API ## Response API
For either `success` or `error`, the following response will be provided. The response for a request contains the following information.
```js
{
// `data` is the response that was provided by the server
data: {},
// `status` is the HTTP status code from the server response
status: 200,
// `headers` the headers that the server responded with
headers: {},
// `config` is the config that was provided to `axios` for the request
config: {}
}
```
When using `then` or `catch`, you will receive a single response object.
```js ```js
axios.get('/user/12345') axios.get('/user/12345')
.success(function ( .then(function(response) {
// `data` is the response that was provided by the server console.log(response.data);
data, console.log(response.status);
console.log(response.headers);
// `status` is the HTTP status code from the server response console.log(response.config);
status, });
```
// `headers` the headers that the server responded with
headers, For either `success` or `error`, the response is broken up into individual arguments.
// `config` is the config that was provided to `axios` for the request ```js
config axios.get('/user/12345')
) { .success(function (data, status, headers, config) {
// Do something with result console.log(data);
console.log(status);
console.log(headers);
console.log(config);
}); });
} }
``` ```