mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
Adding support for URLSearchParams in node (#1900)
* Adding support for URLSearchParams in node * Remove un-needed code * Update utils.js * Make changes as suggested Co-authored-by: Kamil Posiadala <kamil.posiadala@codecentric.de> Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -726,6 +726,14 @@ const querystring = require('querystring');
|
||||
axios.post('http://something.com/', querystring.stringify({ foo: 'bar' }));
|
||||
```
|
||||
|
||||
or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows:
|
||||
|
||||
```js
|
||||
const url = require('url');
|
||||
const params = new url.URLSearchParams({ foo: 'bar' });
|
||||
axios.post('http://something.com/', params.toString());
|
||||
```
|
||||
|
||||
You can also use the [`qs`](https://github.com/ljharb/qs) library.
|
||||
|
||||
###### NOTE
|
||||
|
||||
Reference in New Issue
Block a user