2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +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:
Lim Jing Rong
2018-04-07 11:52:06 +08:00
committed by Justin Beckwith
parent 524f5bf10a
commit cb89fae28f
+14
View File
@@ -598,6 +598,20 @@ var qs = require('qs');
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
In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: