Skip to content

Commit 426081d

Browse files
committed
fix: allow axios to handle the queryParams
1 parent bbfe20c commit 426081d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/generator/clientGenerator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
108108
"const apiClient = getApiClient();",
109109
`const url = ${urlWithParams};`,
110110
queryParams.length > 0
111-
? `const queryData = new URLSearchParams();
112-
${queryParams.map((p) => `if (data["${p.name}"]) { queryData.append("${p.name}", encodeURIComponent(data["${p.name}"]));}`)}`
111+
? `const queryData = {
112+
${queryParams.map((p) => `["${p.name}"]: data["${p.name}"]`).join(",\n ")}
113+
};`
113114
: "",
114115
requestBodySchema?.properties
115116
? `const bodyData = {

0 commit comments

Comments
 (0)