Express获取XML
app.post('/api/wechat/pay/notify', async (req, res) => {
if (!req.is('text/xml') && !req.is('application/xml')) {
return res.send(req.header || req.headers) // 调试header
}
let xml = ''
await new Promise(s => {
req.setEncoding('utf8')
req.on('data', chunk => xml += chunk)
req.on('end', () => {
s(xml)
})
})
console.log(xml)
res.send(xml)
})
906

被折叠的 条评论
为什么被折叠?



