如何使用npm请求模块执行以下操作?
curl -vvvvv -X POST -d "test msg" 'https://app.sms.sender/?destination=12341234' --cacert /loc/to/cert
我尝试这样做:
let options = {
url: format(process.env.PATH_URL, number),
headers: {
'User-Agent': process.env.USER_AGENT
},
agentOptions: {
cert: fs.readFileSync(process.env.SMS_CERT_PATH),
},
body: "test msg"
};
//store url in env
request.post(options, function(error, response, body) {
...
});
但是我一直收到cannot read property 'toString' of undefined