@modern-js/create-request 2.5.1-alpha.7 → 2.5.1-alpha.8

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.
@@ -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 === "functionName") {
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,6 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
86
94
  body = payload.formUrlencoded;
87
95
  }
88
96
  }
89
- } else {
90
- finalURL = path;
91
- body = JSON.stringify({
92
- args
93
- });
94
- headers = {
95
- "Content-Type": "application/json"
96
- };
97
97
  }
98
98
  return fetcher(finalURL, {
99
99
  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 === "functionName") {
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,6 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
93
99
  }
94
100
  }
95
101
  url = `http://localhost:${port}${finalPath}`;
96
- } else {
97
- url = path;
98
- body = args;
99
- headers = {
100
- "Content-Type": "application/json"
101
- };
102
102
  }
103
103
  const fetcher = realRequest || originFetch;
104
104
  return fetcher(url, { method, body, headers });
@@ -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 === "functionName") {
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,6 @@ var createRequest = function(path, method, port) {
225
233
  body = payload.formUrlencoded;
226
234
  }
227
235
  }
228
- } else {
229
- finalURL = path;
230
- body = JSON.stringify({
231
- args: args
232
- });
233
- headers = {
234
- "Content-Type": "application/json"
235
- };
236
236
  }
237
237
  return [
238
238
  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 === "functionName") {
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,6 @@ var createRequest = function(path, method, port) {
117
123
  }
118
124
  }
119
125
  url = "http://localhost:".concat(port).concat(finalPath);
120
- } else {
121
- url = path;
122
- body = args;
123
- headers = {
124
- "Content-Type": "application/json"
125
- };
126
126
  }
127
127
  var fetcher = realRequest || originFetch;
128
128
  return fetcher(url, {
@@ -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 === "functionName") {
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,6 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
57
65
  body = payload.formUrlencoded;
58
66
  }
59
67
  }
60
- } else {
61
- finalURL = path;
62
- body = JSON.stringify({
63
- args
64
- });
65
- headers = {
66
- "Content-Type": "application/json"
67
- };
68
68
  }
69
69
  return fetcher(finalURL, {
70
70
  method,
@@ -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 === "functionName") {
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,6 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
64
70
  }
65
71
  }
66
72
  url = `http://localhost:${port}${finalPath}`;
67
- } else {
68
- url = path;
69
- body = args;
70
- headers = {
71
- "Content-Type": "application/json"
72
- };
73
73
  }
74
74
  const fetcher = realRequest || originFetch;
75
75
  return fetcher(url, { method, body, headers });
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.5.1-alpha.7",
14
+ "version": "2.5.1-alpha.8",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/cjs/index.js",