expressjs使用request发送xml类型请求Content-Type: text/xml

214 阅读1分钟
const app = express()
const request = require('request')
const options = {
  url: 'http://xxx',
  body: req.rawBody,
  headers: {'Content-Type': 'text/xml'}
}

app.use('/apis/xxx', (req, res) => {
  request.post(options, (error, response, body) => {
    if (!error && response.statusCode == 200) {
      console.log(body)
    }
  })
})