Skip to content

Commit cb89fae

Browse files
jjingrongJustinBeckwith
authored andcommitted
docs: Added ES6 example in README (axios#1091)
The alternative way I added is more common and requested, as seen from issues axios#362 , axios#350. Should be helpful for the beginners ( I was personally stuck for a bit too )
1 parent 524f5bf commit cb89fae

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,20 @@ var qs = require('qs');
598598
axios.post('/foo', qs.stringify({ 'bar': 123 }));
599599
```
600600

601+
Or in another way (ES6),
602+
603+
```js
604+
import qs from 'qs';
605+
const data = { 'bar': 123 };
606+
const options = {
607+
method: 'POST',
608+
headers: { 'content-type': 'application/x-www-form-urlencoded' },
609+
data: qs.stringify(data),
610+
url,
611+
};
612+
axios(options);
613+
```
614+
601615
### Node.js
602616

603617
In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:

0 commit comments

Comments
 (0)