Skip to content

Commit 693dc57

Browse files
committed
omit empty values when sending post body
1 parent e889d79 commit 693dc57

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/JsonService.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,19 @@ export class JsonService {
167167

168168
let body = "";
169169
for(let key in payload) {
170-
if (body.length > 0) {
171-
body += "&";
170+
171+
let value = payload[key];
172+
173+
if (value) {
174+
175+
if (body.length > 0) {
176+
body += "&";
177+
}
178+
179+
body += encodeURIComponent(key);
180+
body += "=";
181+
body += encodeURIComponent(value);
172182
}
173-
body += encodeURIComponent(key);
174-
body += "=";
175-
body += encodeURIComponent(payload[key]);
176183
}
177184

178185
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

0 commit comments

Comments
 (0)