Skip to content

Commit bcced8b

Browse files
Chantouch SekChantouch Sek
authored andcommitted
fix: 🐛 fixed a bug where parameters reset when use shorthand set params
1 parent 2b1b621 commit bcced8b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-api-queries",
3-
"version": "0.0.13",
3+
"version": "0.0.14",
44
"description": "Elegant and simple way to build requests for REST API",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/core/BaseProxy.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class BaseProxy {
103103
return parameters.length === 0 ? url : `${url}?${parameters.join('&')}`
104104
}
105105

106-
__getQueryString(parameter: string): string[] {
106+
__getQueryString(parameter: string): any | any[] {
107107
const queries: string[] = parameter.split('&')
108108
const obj: any = {}
109109
queries.forEach(function (property: string) {
@@ -180,7 +180,10 @@ class BaseProxy {
180180

181181
setParameter(parameter: string, value?: any): this {
182182
if (!value) {
183-
this.parameters = this.__getQueryString(parameter)
183+
const params = this.__getQueryString(parameter)
184+
Object.entries(params).forEach(
185+
([key, value]) => (this.parameters[key] = value),
186+
)
184187
return this
185188
}
186189
this.parameters[parameter] = value

0 commit comments

Comments
 (0)