简体   繁体   中英

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

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);
const call = device.connect();
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 ?

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM