我将Twilio SDK用于我的邮递员请求。 我现在已经将凭据存储在.env文件中。
exports.send = async (messageBody) => {
client.messages.create({
body: messageBody,
To: twilioTo,
From: twilioFrom
}, (err, message) => {
message = message + " Goodbye World!";
if (err) return cb(err);
cb(null, message);
});
};
但是得到的不是正常反应
{
"code": 500,
"message": "Required parameter \"opts.to\" missing.",
"stack": "Error: Required parameter \"opts.to\" missing.\n at Function.create (/Volumes/BOOTCAMP/knowrify/knowrify-node-backend/node_modules/twilio/lib/rest/api/v2010/account/message.js:95:13)\n at Object.exports.send (/Volumes/BOOTCAMP/knowrify/knowrify-node-backend/src/api/services/twilioSMSVerficationService.js:14:21)\n at exports.send (/Volumes/BOOTCAMP/knowrify/knowrify-node-backend/src/api/controllers/twilio.controller.js:20:42)\n at Layer.handle [as handle_request] (/Volumes/BOOTCAMP/knowrify/knowrify-node-backend/node_modules/express/lib/router/layer.js:95:5)\n at next (/Volumes/BOOTCAMP/knowrify/knowrify-node-backend/node_modules/express/lib/router/route.js:137:13)\n at /Volumes/BOOTCAMP/knowrify/knowrify-node-backend/src/api/middlewares/auth.js:41:10"
}