node express 微信xml消息接收解析配置

1、npm install -s  body-parser body-parser-xml   安装npm包

2、在app中配置

const bodyParser = require("body-parser");
require("body-parser-xml")(bodyParser);//微信支付解析xml
var app = express();
app.use(bodyParser.xml({
  limit: "1MB",
  xmlParseOptions: {
    normalize: true,
    normalizeTags: true,
    explicitArray: false
  },
  verify: function(req, res, buf, encoding) {
    if (buf && buf.length) {
      req.rawBody = buf.toString(encoding || "utf8");
    }
  }
}));
上一篇:【Express】起步 - 路由基础 - 请求对象request - 响应对象response - 增删改查API案例


下一篇:Google Proposes to Enhance JSON with Jsonnet