const rXml = await this.fetch('https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers', {
method: 'POST',
body: xmlData,
agentOptions: {
cert: fs.readFileSync(path.join(__dirname, '../apiclient_cert.pem')).toString(),
key: fs.readFileSync(path.join(__dirname, '../apiclient_key.pem')).toString()
}
}).then(res => res.text());
fs.readFileSync(path.join(__dirname,'../apiclient_cert.pem')).toString()
把上面这个打印一下看下有没有输出,另外这个可以不用 `toString`,参数是接受`buffer`类型的
const rXml = await this.fetch('https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers', {
method: 'POST',
body: xmlData,
agent: () => {
return new require('https').Agent({
keepAlive: true,
cert: fs.readFileSync(path.join(__dirname, '../apiclient_cert.pem')),
key: fs.readFileSync(path.join(__dirname, '../apiclient_key.pem'))
})
}
}).then(res => res.text());
服务器上对应路径下面已经上传了证书