Skip to content

Commit

Permalink
use URLSearchParams native node function
Browse files Browse the repository at this point in the history
  • Loading branch information
HEYGUL committed Dec 11, 2023
1 parent 1a10f49 commit dc8866f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Expand Up @@ -2,18 +2,18 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['superagent', 'querystring'], factory);
define(['superagent'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('superagent'), require('querystring'));
module.exports = factory(require('superagent'));
} else {
// Browser globals (root is window)
if (!root.{{moduleName}}) {
root.{{moduleName}} = {};
}
root.{{moduleName}}.ApiClient = factory(root.superagent, root.querystring);
root.{{moduleName}}.ApiClient = factory(root.superagent);
}
}(this, function(superagent, querystring) {
}(this, function(superagent) {
'use strict';
{{#emitJSDoc}} /**
Expand Down Expand Up @@ -432,7 +432,8 @@
}

if (contentType === 'application/x-www-form-urlencoded') {
request.send(querystring.stringify(this.normalizeParams(formParams)));
const searchParams = new URLSearchParams(this.normalizeParams(formParams));
request.send(searchParams.toString());
} else if (contentType == 'multipart/form-data') {
var _formParams = this.normalizeParams(formParams);
for (var key in _formParams) {
Expand Down
@@ -1,6 +1,5 @@
{{>licenseInfo}}
import superagent from "superagent";
import querystring from "querystring";

{{#emitJSDoc}}/**
* @module {{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient
Expand Down Expand Up @@ -420,7 +419,8 @@ export class ApiClient {
}

if (contentType === 'application/x-www-form-urlencoded') {
request.send(querystring.stringify(this.normalizeParams(formParams)));
const searchParams = new URLSearchParams(this.normalizeParams(formParams));
request.send(searchParams.toString());
} else if (contentType == 'multipart/form-data') {
var _formParams = this.normalizeParams(formParams);
for (var key in _formParams) {
Expand Down
Expand Up @@ -11,8 +11,7 @@
"fs": false
},
"dependencies": {
"superagent": "3.7.0",
"querystring": "0.2.0"
"superagent": "3.7.0"
},
"devDependencies": {
"mocha": "~2.3.4",
Expand Down

0 comments on commit dc8866f

Please sign in to comment.