@modern-js/create-request 2.5.1-alpha.7 → 2.5.1-alpha.9
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/dist/cjs/browser.js +12 -9
- package/dist/cjs/node.js +10 -7
- package/dist/esm/browser.js +12 -9
- package/dist/esm/node.js +10 -7
- package/dist/esm-node/browser.js +12 -9
- package/dist/esm-node/node.js +10 -7
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -52,7 +52,15 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
|
|
|
52
52
|
let body;
|
|
53
53
|
let finalURL;
|
|
54
54
|
let headers;
|
|
55
|
-
if (httpMethodDecider === "
|
|
55
|
+
if (httpMethodDecider === "inputParams") {
|
|
56
|
+
finalURL = path;
|
|
57
|
+
body = JSON.stringify({
|
|
58
|
+
args
|
|
59
|
+
});
|
|
60
|
+
headers = {
|
|
61
|
+
"Content-Type": "application/json"
|
|
62
|
+
};
|
|
63
|
+
} else {
|
|
56
64
|
const payload = typeof args[args.length - 1] === "object" ? args[args.length - 1] : {};
|
|
57
65
|
payload.params = payload.params || {};
|
|
58
66
|
const requestParams = args[0];
|
|
@@ -86,14 +94,9 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
|
|
|
86
94
|
body = payload.formUrlencoded;
|
|
87
95
|
}
|
|
88
96
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
body =
|
|
92
|
-
args
|
|
93
|
-
});
|
|
94
|
-
headers = {
|
|
95
|
-
"Content-Type": "application/json"
|
|
96
|
-
};
|
|
97
|
+
}
|
|
98
|
+
if (method.toLowerCase() === "get") {
|
|
99
|
+
body = void 0;
|
|
97
100
|
}
|
|
98
101
|
return fetcher(finalURL, {
|
|
99
102
|
method,
|
package/dist/cjs/node.js
CHANGED
|
@@ -54,7 +54,13 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
|
|
|
54
54
|
let body;
|
|
55
55
|
let headers;
|
|
56
56
|
let url;
|
|
57
|
-
if (httpMethodDecider === "
|
|
57
|
+
if (httpMethodDecider === "inputParams") {
|
|
58
|
+
url = path;
|
|
59
|
+
body = args;
|
|
60
|
+
headers = {
|
|
61
|
+
"Content-Type": "application/json"
|
|
62
|
+
};
|
|
63
|
+
} else {
|
|
58
64
|
const payload = typeof args[args.length - 1] === "object" ? args[args.length - 1] : {};
|
|
59
65
|
payload.params = payload.params || {};
|
|
60
66
|
const requestParams = args[0];
|
|
@@ -93,12 +99,9 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
|
|
|
93
99
|
}
|
|
94
100
|
}
|
|
95
101
|
url = `http://localhost:${port}${finalPath}`;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
body =
|
|
99
|
-
headers = {
|
|
100
|
-
"Content-Type": "application/json"
|
|
101
|
-
};
|
|
102
|
+
}
|
|
103
|
+
if (method.toLowerCase() === "get") {
|
|
104
|
+
body = void 0;
|
|
102
105
|
}
|
|
103
106
|
const fetcher = realRequest || originFetch;
|
|
104
107
|
return fetcher(url, { method, body, headers });
|
package/dist/esm/browser.js
CHANGED
|
@@ -191,7 +191,15 @@ var createRequest = function(path, method, port) {
|
|
|
191
191
|
args[_key] = _arguments[_key];
|
|
192
192
|
}
|
|
193
193
|
fetcher = realRequest || originFetch;
|
|
194
|
-
if (httpMethodDecider === "
|
|
194
|
+
if (httpMethodDecider === "inputParams") {
|
|
195
|
+
finalURL = path;
|
|
196
|
+
body = JSON.stringify({
|
|
197
|
+
args: args
|
|
198
|
+
});
|
|
199
|
+
headers = {
|
|
200
|
+
"Content-Type": "application/json"
|
|
201
|
+
};
|
|
202
|
+
} else {
|
|
195
203
|
payload = typeof args[args.length - 1] === "object" ? args[args.length - 1] : {};
|
|
196
204
|
payload.params = payload.params || {};
|
|
197
205
|
requestParams = args[0];
|
|
@@ -225,14 +233,9 @@ var createRequest = function(path, method, port) {
|
|
|
225
233
|
body = payload.formUrlencoded;
|
|
226
234
|
}
|
|
227
235
|
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
body =
|
|
231
|
-
args: args
|
|
232
|
-
});
|
|
233
|
-
headers = {
|
|
234
|
-
"Content-Type": "application/json"
|
|
235
|
-
};
|
|
236
|
+
}
|
|
237
|
+
if (method.toLowerCase() === "get") {
|
|
238
|
+
body = void 0;
|
|
236
239
|
}
|
|
237
240
|
return [
|
|
238
241
|
2,
|
package/dist/esm/node.js
CHANGED
|
@@ -61,7 +61,13 @@ var createRequest = function(path, method, port) {
|
|
|
61
61
|
var body;
|
|
62
62
|
var headers;
|
|
63
63
|
var url;
|
|
64
|
-
if (httpMethodDecider === "
|
|
64
|
+
if (httpMethodDecider === "inputParams") {
|
|
65
|
+
url = path;
|
|
66
|
+
body = args;
|
|
67
|
+
headers = {
|
|
68
|
+
"Content-Type": "application/json"
|
|
69
|
+
};
|
|
70
|
+
} else {
|
|
65
71
|
var payload = typeof args[args.length - 1] === "object" ? args[args.length - 1] : {};
|
|
66
72
|
payload.params = payload.params || {};
|
|
67
73
|
var requestParams = args[0];
|
|
@@ -117,12 +123,9 @@ var createRequest = function(path, method, port) {
|
|
|
117
123
|
}
|
|
118
124
|
}
|
|
119
125
|
url = "http://localhost:".concat(port).concat(finalPath);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
body =
|
|
123
|
-
headers = {
|
|
124
|
-
"Content-Type": "application/json"
|
|
125
|
-
};
|
|
126
|
+
}
|
|
127
|
+
if (method.toLowerCase() === "get") {
|
|
128
|
+
body = void 0;
|
|
126
129
|
}
|
|
127
130
|
var fetcher = realRequest || originFetch;
|
|
128
131
|
return fetcher(url, {
|
package/dist/esm-node/browser.js
CHANGED
|
@@ -23,7 +23,15 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
|
|
|
23
23
|
let body;
|
|
24
24
|
let finalURL;
|
|
25
25
|
let headers;
|
|
26
|
-
if (httpMethodDecider === "
|
|
26
|
+
if (httpMethodDecider === "inputParams") {
|
|
27
|
+
finalURL = path;
|
|
28
|
+
body = JSON.stringify({
|
|
29
|
+
args
|
|
30
|
+
});
|
|
31
|
+
headers = {
|
|
32
|
+
"Content-Type": "application/json"
|
|
33
|
+
};
|
|
34
|
+
} else {
|
|
27
35
|
const payload = typeof args[args.length - 1] === "object" ? args[args.length - 1] : {};
|
|
28
36
|
payload.params = payload.params || {};
|
|
29
37
|
const requestParams = args[0];
|
|
@@ -57,14 +65,9 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
|
|
|
57
65
|
body = payload.formUrlencoded;
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
body =
|
|
63
|
-
args
|
|
64
|
-
});
|
|
65
|
-
headers = {
|
|
66
|
-
"Content-Type": "application/json"
|
|
67
|
-
};
|
|
68
|
+
}
|
|
69
|
+
if (method.toLowerCase() === "get") {
|
|
70
|
+
body = void 0;
|
|
68
71
|
}
|
|
69
72
|
return fetcher(finalURL, {
|
|
70
73
|
method,
|
package/dist/esm-node/node.js
CHANGED
|
@@ -25,7 +25,13 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
|
|
|
25
25
|
let body;
|
|
26
26
|
let headers;
|
|
27
27
|
let url;
|
|
28
|
-
if (httpMethodDecider === "
|
|
28
|
+
if (httpMethodDecider === "inputParams") {
|
|
29
|
+
url = path;
|
|
30
|
+
body = args;
|
|
31
|
+
headers = {
|
|
32
|
+
"Content-Type": "application/json"
|
|
33
|
+
};
|
|
34
|
+
} else {
|
|
29
35
|
const payload = typeof args[args.length - 1] === "object" ? args[args.length - 1] : {};
|
|
30
36
|
payload.params = payload.params || {};
|
|
31
37
|
const requestParams = args[0];
|
|
@@ -64,12 +70,9 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
|
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
url = `http://localhost:${port}${finalPath}`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
body =
|
|
70
|
-
headers = {
|
|
71
|
-
"Content-Type": "application/json"
|
|
72
|
-
};
|
|
73
|
+
}
|
|
74
|
+
if (method.toLowerCase() === "get") {
|
|
75
|
+
body = void 0;
|
|
73
76
|
}
|
|
74
77
|
const fetcher = realRequest || originFetch;
|
|
75
78
|
return fetcher(url, { method, body, headers });
|