mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
docs: Added ES6 example in README (#1091)
The alternative way I added is more common and requested, as seen from issues #362 , #350. Should be helpful for the beginners ( I was personally stuck for a bit too )
This commit is contained in:
committed by
Justin Beckwith
parent
524f5bf10a
commit
cb89fae28f
@@ -598,6 +598,20 @@ var qs = require('qs');
|
|||||||
axios.post('/foo', qs.stringify({ 'bar': 123 }));
|
axios.post('/foo', qs.stringify({ 'bar': 123 }));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or in another way (ES6),
|
||||||
|
|
||||||
|
```js
|
||||||
|
import qs from 'qs';
|
||||||
|
const data = { 'bar': 123 };
|
||||||
|
const options = {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||||
|
data: qs.stringify(data),
|
||||||
|
url,
|
||||||
|
};
|
||||||
|
axios(options);
|
||||||
|
```
|
||||||
|
|
||||||
### Node.js
|
### Node.js
|
||||||
|
|
||||||
In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:
|
In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:
|
||||||
|
|||||||
Reference in New Issue
Block a user