2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +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
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
axios.get('/user/12345')
.success(function (
// `data` is the response that was provided by the server
data,
// `status` is the HTTP status code from the server response
status,
// `headers` the headers that the server responded with
headers,
// `config` is the config that was provided to `axios` for the request
config
) {
// Do something with result
.then(function(response) {
console.log(response.data);
console.log(response.status);
console.log(response.headers);
console.log(response.config);
});
```
For either `success` or `error`, the response is broken up into individual arguments.
```js
axios.get('/user/12345')
.success(function (data, status, headers, config) {
console.log(data);
console.log(status);
console.log(headers);
console.log(config);
});
}
```