in order to make it convenient for testers to view APP interface request and response messages, Mini Program is written by using express. When you click APP, you can always output request and response messages under the terminal.
take iOS as an example, the interface implemented by express is called at the request and response of the communication package, and the request and response messages are transmitted in the form of POST parameters and printed on the terminal.
problem encountered:
after the App side requests two or three APIs, the request and response on the terminal side will not respond and cannot be printed for half a day.
finally outputs POST /-- ms--, which seems to have timed out.
now you can only control+c out of the service, restart the service, and then request the interface to respond quickly.
I don"t know much about node, so it"s troublesome to quit frequently and restart the service.
any boss who has experience in similar problems still needs advice, thank you!
var express = require("express");
var router = express.Router();
var bodyParser = require("body-parser");
router.use(bodyParser.json());
router.use(bodyParser.urlencoded({ extended: true }));
router.post("/", function (req, res, next) {
var bodyString = JSON.stringify(req.body)
//
if (req.body.request) {
console.log(":");
console.log(bodyString);
console.log(" ");
}
//
if (req.body.response) {
console.log(":");
console.log(bodyString);
console.log(" ");
}
})
module.exports = router;