@readme/httpsnippet 3.1.2 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/targets/r/httr.js +5 -8
package/package.json
CHANGED
package/src/targets/r/httr.js
CHANGED
|
@@ -23,20 +23,17 @@ module.exports = function (source) {
|
|
|
23
23
|
|
|
24
24
|
// Construct query string
|
|
25
25
|
const qs = source.queryObj;
|
|
26
|
-
const queryCount = Object.keys(qs).length;
|
|
27
26
|
// eslint-disable-next-line no-param-reassign
|
|
28
27
|
delete source.queryObj.key;
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
const queryCount = Object.keys(qs).length;
|
|
30
|
+
if (queryCount === 1) {
|
|
31
31
|
code.push('queryString <- list(%s = "%s")', Object.keys(qs), Object.values(qs).toString()).blank();
|
|
32
|
-
} else if (
|
|
33
|
-
let count = 1;
|
|
34
|
-
|
|
32
|
+
} else if (queryCount > 1) {
|
|
35
33
|
code.push('queryString <- list(');
|
|
36
34
|
|
|
37
|
-
Object.keys(qs).forEach(query => {
|
|
38
|
-
|
|
39
|
-
if (count++ !== queryCount - 1) {
|
|
35
|
+
Object.keys(qs).forEach((query, i) => {
|
|
36
|
+
if (i !== queryCount - 1) {
|
|
40
37
|
code.push(' %s = "%s",', query, qs[query].toString());
|
|
41
38
|
} else {
|
|
42
39
|
code.push(' %s = "%s"', query, qs[query].toString());
|