From 679ec09b39482e58c583bc9230339441f18229c5 Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Tue, 16 Sep 2014 12:03:46 -0600 Subject: [PATCH] Updating README --- README.md | 51 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 454fac2..08e152e 100644 --- a/README.md +++ b/README.md @@ -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); }); } ```