编程语言
首页 > 编程语言> > node express 微信xml消息接收解析配置

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");
    }
  }
}));

标签:node,xml,微信,app,parser,body,bodyParser,buf
来源: https://blog.csdn.net/xw245184020/article/details/100899367