0

I am attempting to use the Example from Get Recording and I get the error message: "TypeError: Parameter auth is deprecated. Use username / password instead." How do I change the following code to make this work. Here is my Code:

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);
    });
};
ScottH
  • 41
  • 4

1 Answers1

0
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);
    });
};
Alan
  • 10,465
  • 2
  • 8
  • 9