From cb89fae28f2372955ffdbb153034f612efc31b6c Mon Sep 17 00:00:00 2001 From: Lim Jing Rong Date: Sat, 7 Apr 2018 11:52:06 +0800 Subject: [PATCH] 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 ) --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 1b66d04..bf0d796 100755 --- a/README.md +++ b/README.md @@ -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: