@less-is-more/less-js 1.2.33 → 1.2.34
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/router.js +9 -6
package/package.json
CHANGED
package/src/router.js
CHANGED
|
@@ -72,19 +72,22 @@ module.exports = class Router {
|
|
|
72
72
|
const isFile =
|
|
73
73
|
req.headers &&
|
|
74
74
|
JSON.stringify(req.headers).includes("multipart/form-data");
|
|
75
|
-
|
|
76
|
-
req.headers &&
|
|
77
|
-
JSON.stringify(req.headers).includes("application/json");
|
|
75
|
+
const isJson =
|
|
76
|
+
req.headers && JSON.stringify(req.headers).includes("application/json");
|
|
78
77
|
console.log("multipart:", isFile);
|
|
79
78
|
if (req.method == "POST") {
|
|
80
79
|
if (isFile) {
|
|
81
80
|
await this._getFile(req);
|
|
82
81
|
console.log("params:", req.params);
|
|
83
82
|
console.log("files:", req.files);
|
|
84
|
-
}else if(isJson){
|
|
83
|
+
} else if (isJson) {
|
|
85
84
|
const data = await promisify(body)(req);
|
|
86
|
-
console.log("body: " +
|
|
87
|
-
|
|
85
|
+
console.log("body: " + data);
|
|
86
|
+
try {
|
|
87
|
+
req.body = JSON.parse(data);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
console.error("body格式错误", data);
|
|
90
|
+
}
|
|
88
91
|
} else {
|
|
89
92
|
const data = await promisify(body)(req);
|
|
90
93
|
console.log("body: " + decodeURIComponent(data));
|