error when I instantiate Twilio.Call function - Undefined 'info'

93 views Asked by At

I am trying to make an outbound call with Twilio Voice SDK in HTML.

I am getting the following error when I instantiate Twilio.Call function

const device = new Device(token);
 params = {
        params: {
            To: phone
        }
    };
const call = device.connect(params);
var callTemp = new Twilio.Call(call);

Error

Uncaught TypeError: Cannot read properties of undefined (reading 'info')
at Object.Call (twilio.min.js:1:26960)
at HTMLDivElement.eval (eval at <anonymous> (jquery.min.js:4:4994), <anonymous>:501:20)
at HTMLDivElement.dispatch (jquery.min.js:5:14129)
at v.handle (jquery.min.js:5:10866)

What is the correct way to instantiate the Twilio.Call?

1

There are 1 answers

2
philnash On

You should not instantiate a Twilio.Call object yourself. The method device.connect returns a promise that resolves to a Twilio.Call object.

const device = new Device(token);
device.connect().then(call => {
  // Now you have the Twilio.Call object
})

Or with async/await:

const device = new Device(token);
const call = await device.connect();