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

Updating README

This commit is contained in:
Matt Zabriskie
2014-08-29 16:36:09 -06:00
parent d441f8392f
commit 9608790380
+22 -10
View File
@@ -1,6 +1,14 @@
# axios [![Build Status](https://travis-ci.org/mzabriskie/axios.svg?branch=master)](https://travis-ci.org/mzabriskie/axios) # axios [![Build Status](https://travis-ci.org/mzabriskie/axios.svg?branch=master)](https://travis-ci.org/mzabriskie/axios)
Lightweight Promise based XHR library Promise based XHR library
## Features
- Making [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) supporting the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API
- Transforming request and response data
- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery)
- Specifying HTTP request headers
- Automatic transforms for JSON data
## Example ## Example
@@ -56,8 +64,8 @@ Requests can be made by passing the relevant config to `axios`.
```js ```js
axios({ axios({
url: '/user/12345', method: 'get',
method: 'get' url: '/user/12345'
}); });
``` ```
@@ -135,19 +143,23 @@ When using the alias methods `url`, `method`, and `data` properties don't need t
For either `success` or `error`, the following response will be provided. For either `success` or `error`, the following response will be provided.
```js ```
{ axios.get('/user/12345')
.success(function (
// `data` is the response that was provided by the server // `data` is the response that was provided by the server
data: {/*...*/} , data,
// `status` is the HTTP status code from the server response // `status` is the HTTP status code from the server response
status: 200, status,
// `headers` the headers that the server responded with // `headers` the headers that the server responded with
headers: {/*...*/}, headers,
// `config` is the config that were provided to `axios` for the request // `config` is the config that were provided to `axios` for the request
config: {/*...*/} config
) {
// Do something with result
});
} }
``` ```
@@ -169,7 +181,7 @@ $ npm install axios
Tested to work with >=IE8, Chrome, Firefox, Safari, and Opera. Tested to work with >=IE8, Chrome, Firefox, Safari, and Opera.
## Attribution ## Thanks
axios is heavily inspired by Angular's $http service. axios is heavily inspired by Angular's $http service.