Twilio函数检索语音邮件TypeError:参数"auth"已弃用.请改用"用户名&q



我正试图使用GetRecording中的示例,并收到错误消息:"TypeError:参数auth已弃用。请改用username/password"如何更改以下代码以使其工作。这是我的代码:

const got = require('got');
//Boilerplate for function code
exports.handler = function(context, event, callback) {
// Make an HTTP Request using a template literal for the Twilio API call
//https://api.twilio.com/2010-04-01/Accounts/${context.ACCOUNT_SID}/Recordings.json
got('https://api.twilio.com/2010-04-01/Accounts/${context.ACCOUNT_SID}/Recordings.json', {
method:'get',
auth: '${context.ACCOUNT_SID}:${context.AUTH_TOKEN}'
})
.then(res => {
console.log(res);
callback(null, res.body);
})
.catch(err => {
console.log(err);
callback(err);
});
};
const got = require('got');
//Boilerplate for function code
exports.handler = function(context, event, callback) {
// Make an HTTP Request using a template literal for the Twilio API call
//https://api.twilio.com/2010-04-01/Accounts/${context.ACCOUNT_SID}/Recordings.json
got(`https://api.twilio.com/2010-04-01/Accounts/${context.ACCOUNT_SID}/Recordings.json`, {
method:'get',
username: context.ACCOUNT_SID,
password: context.AUTH_TOKEN
})
.then(res => {
console.log(res);
callback(null, res.body);
})
.catch(err => {
console.log(err);
callback(err);
});
};

最新更新